Skip to content

Commit

Permalink
feat: ParseComment error to contain the comment
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 committed Mar 20, 2024
1 parent 91624ad commit a7ca68f
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 @@ -386,7 +386,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 @@ -1027,7 +1027,7 @@ DeclsLoop:
for _, comment := range astDeclaration.Doc.List {
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 {
continue DeclsLoop
Expand Down

0 comments on commit a7ca68f

Please sign in to comment.