From b506fa66b13586e914fdc0bbce58fecc199e76a8 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 22 Oct 2024 00:38:19 +0300 Subject: [PATCH] feat: ParseComment error to contain the comment (#1777) 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. --- operation.go | 2 +- parser.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/operation.go b/operation.go index cbc6ce2cc..acb1d383e 100644 --- a/operation.go +++ b/operation.go @@ -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, ¶m) diff --git a/parser.go b/parser.go index d10003b01..1bd808e4e 100644 --- a/parser.go +++ b/parser.go @@ -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