-
Notifications
You must be signed in to change notification settings - Fork 3
Made error messages in CLI more user friendly #222
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
Conversation
Difference in output when info flag is given compared to when debug flag is givenDEBUG FLAG
INFO FLAG
|
} else if (!"".equals(exception.getMessage())) { | ||
err(exception.getMessage()); | ||
} else if ("".equals(message)) { | ||
err("An unknown error has occurred. Consider rerunning with --debug"); |
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.
Should I be advising users to rerun with --debug
?
Also, I will change --debug
to the DEBUG
constant once #221 is merged.
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.
Should I be advising users to rerun with
--debug
?
That make sense, although we don't have too many LOG.debug
statements. But we have enough.
if (LOG.isInfoEnabled()) { | ||
LOG.error(arg); | ||
} else { | ||
System.err.println(ERROR_MESSAGE_START + arg); |
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.
Use io.dockstore.client.cli.ArgumentUtility#err for consistency.
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.
This is where err
is defined. Would it better to call this method, printError
and define err
to be System.err.println
?
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.
🤦 Ignore my comment.
} else if (!"".equals(exception.getMessage())) { | ||
err(exception.getMessage()); | ||
} else if ("".equals(message)) { | ||
err("An unknown error has occurred. Consider rerunning with --debug"); |
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.
Should I be advising users to rerun with
--debug
?
That make sense, although we don't have too many LOG.debug
statements. But we have enough.
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.
Looks good in principle, awaiting build success
…clean-up-error-messages
if (LOG.isInfoEnabled()) { | ||
LOG.error(arg); | ||
} else { | ||
System.err.println(ERROR_MESSAGE_START + arg); |
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.
🤦 Ignore my comment.
Codecov ReportBase: 69.39% // Head: 69.65% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #222 +/- ##
=============================================
+ Coverage 69.39% 69.65% +0.26%
- Complexity 1050 1069 +19
=============================================
Files 47 47
Lines 6034 6041 +7
Branches 789 792 +3
=============================================
+ Hits 4187 4208 +21
+ Misses 1515 1510 -5
+ Partials 332 323 -9
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I think this suggestion from SonarCloud would just complicate things and make them less readable in this situation. |
} | ||
|
||
private static void errFormatted(String format, Object... args) { | ||
LOG.error((String.format(format, args))); | ||
if (LOG.isInfoEnabled()) { | ||
LOG.error(String.format(format, args)); |
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.
We might be able to eliminate some duplicate code by replacing the body of this function with a call to err(String.format(format, args))
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, I have now done this.
|
||
if (LOG.isInfoEnabled()) { | ||
err(ExceptionUtils.getStackTrace(exception)); | ||
} else if (exception.getMessage() != null && !"".equals(exception.getMessage())) { |
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.
StringUtils.isNotEmpty
would make this clearer: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#isNotEmpty-java.lang.CharSequence-
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, I have now done this.
Kudos, SonarCloud Quality Gate passed! |
Description
This PR improves the readability of error messages given in the CLI. If the
--debug
or--info
is not given then the CLI will only display (inSystem.err
)Where
<ERROR_MESSAGE>
is:message
if it is given when exceptionMessage is called"An unknown error has occurred. Consider rerunning with --debug"
if the above two are not availableI am using
LOG.isInfoEnabled()
to determine whether I should the "nice" output, or the output with the stack traces. This is because it will allow developers to use the--info
flag instead of the--debug
flag to see the output. As the--debug
flag creates a lot of output. I have made a comment showing the difference in output when--debug
is used, as compared to--info
.Examples of error messages
Before
After
Before
After
Review Instructions
Verify that error messages are given to users in a user-friendly way.
Ensure that error messages are still given to users and that the error messages are helpful.
Issue
dockstore/dockstore#5223
DOCK-2275
Security
If there are any concerns that require extra attention from the security team, highlight them here.
Please make sure that you've checked the following before submitting your pull request. Thanks!
./mvnw clean install