-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix clilog
file names for link errors
#31
Conversation
Signed-off-by: Saswata Mukherjee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Some implementation nits only
@@ -201,14 +201,23 @@ func (v *validator) Close(ctx mdformatter.SourceContext) error { | |||
}) | |||
|
|||
merr := merrors.New() | |||
base, err := os.Getwd() | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of things:
merr.Add
already checks iferr != nil
so no need to check again- Don't wrap with
Wrapf
if there is no argument, use justWrap
- No need to say something failed - you are wrapping failure after all, so just
resolve working dir
would be ok - Are we sure we want to continue after those errors and not fail whole thing? why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes! Would be better to fail whole thing and return error rather than add to merr
. Will implement this! Would need to keep err != nil
checks in this case.
Signed-off-by: Saswata Mukherjee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 💪🏽 Solid
Fixes #28.
Currently, link checking errors are handled by merrors and are pretty printed when
log.format
is set toclilog
(this is set to default since it is human-readable). However the filenames of the relevant errors are not shown inclilog
even though it is wrapped. This is due to thePrettyPrint
function which in turn callserrors.As()
. According to docs the passed in error is repeatedly unwrapped which causes us to lose the filename. There is also no way to pass in the filename without losing the pretty print functionality,This PR fixes this by wrapping each error with the relative path of the file it originates from thus allowing us to have logs like below,