-
Notifications
You must be signed in to change notification settings - Fork 49
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
Improve Error Messages for Harbor CLI #262
Comments
@bupd These messages can overwhelm or confuse end-users as they often contain details such as system codes, addresses, or stack traces that are not meaningful to them. Proposed SolutionThe aim is to make error messages more user-facing by:
The updated error-handling approach will focus on guiding the user through potential issues rather than exposing internal system details. For example, instead of returning raw error information, we will return concise, actionable messages tailored to specific error types. Example ImplementationBelow is an example of how we can handle errors more effectively: Current Implementation if err != nil {
return err
} Proposed Implementation if err != nil {
// Check if the error is from a specific error type or code
if apiErr, ok := err.(*project.DeleteProjectBadRequest); ok {
log.Errorf("Bad request while trying to delete project %s: %v", projectName, apiErr)
return errors.New("Invalid request to delete project")
}
if apiErr, ok := err.(*project.DeleteProjectNotFound); ok {
log.Errorf("Project %s not found: %v", projectName, apiErr)
return errors.New("Project not found or already deleted")
}
if apiErr, ok := err.(*project.DeleteProjectForbidden); ok {
log.Errorf("Permission denied for project %s: %v", projectName, apiErr)
return errors.New("Insufficient permissions to delete project")
}
// Generic error handling if the error type is unknown
log.Errorf("Failed to delete project %s: %v", projectName, err)
return errors.New("An unexpected error occurred while deleting the project")
} Expected Outcome
Example of User-Facing Messages
|
@Roaster05 Thanks for the suggestions. If you are up for it create a PR. Also, We don't need the ERROR: Project not found or already deleted The above would be one good example of the error message |
Hey @bupd i have made a draft PR #282 for the same could you please have a look at it |
The prefix we see in the front of all error messages is created by this library we are using. I would prefer using slog. |
The current error messages in the Harbor CLI provide detailed technical information, which is useful for debugging but not ideal for end-users. These error messages are too verbose and can overwhelm or confuse users. We need to modify the error messages to be more user-facing and focused on guiding the user through potential issues.
Expected outcome:
The prefix we see in the front of all error messages is created by this library we are using.
TO remove the prefix, We should either switch completely to
fmt
or useslog
.The text was updated successfully, but these errors were encountered: