-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add a method to set a public-facing message #22
Conversation
OMG, you're a genius. I've seen such a thing in In terms of API, I wonder if we should add a getter such as: func GetPublic(err error, defaultPublicMessage string) string {
var oopsError oops.OopsError
if errors.As(err, &oopsError) {
msg := oopsError.Public()
if len(msg) > 0 {
return msg
}
return defaultPublicMessage
}
} |
BTW, the error builder brings a ".Code(string)" method if your error is a key. |
I like that, I'll push it up. |
I saw that, but I'm not enterprise enough to define error codes yet 😆 |
"work in progress" 🫣 |
@knpwrs sorry for the late comment: I wonder if we should call this method |
|
ok, lets keep public then |
The idea here is to provide a consistent key for error messages that are guaranteed to be safe to show to an end user. My use case is a global error handler for a web application that can result in error messages being shown on the screen, but I don't want to show just any message for any error, I want to only show strings that I know are deemed appropriate for end users to see.