Skip to content

Commit

Permalink
feat: ParseComment error to contain the comment (#1777)
Browse files Browse the repository at this point in the history
When a comment has an error then we print only a file name and the error text but not the comment that caused an error.
To make it easier to understand a problem print it.

Also change an error itself to make it easier to google.
  • Loading branch information
stokito authored Oct 21, 2024
1 parent 3975e5b commit b506fa6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (operation *Operation) ParseParamComment(commentLine string, astFile *ast.F
param.Schema = schema
}
default:
return fmt.Errorf("%s is not supported paramType", paramType)
return fmt.Errorf("not supported paramType: %s", paramType)
}

err := operation.parseParamAttribute(commentLine, objectType, refType, paramType, &param)
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ func (parser *Parser) parseRouterAPIInfoComment(comments []*ast.Comment, fileInf
for _, comment := range comments {
err := operation.ParseComment(comment.Text, fileInfo.File)
if err != nil {
return fmt.Errorf("ParseComment error in file %s :%+v", fileInfo.Path, err)
return fmt.Errorf("ParseComment error in file %s for comment: '%s': %+v", fileInfo.Path, comment.Text, err)
}
if operation.State != "" && operation.State != parser.HostState {
return nil
Expand Down

0 comments on commit b506fa6

Please sign in to comment.