4 ms·
I agree that they are awkward. I've solved it similarly by defining a custom handleFunc [1] and a custom errHTTP struct [2] which contains the HTTP response cod
by binwiederhier 4y ago
I agree that they are awkward. I've solved it similarly by defining a custom handleFunc [1] and a custom errHTTP struct [2] which contains the HTTP response code and even more detailed error codes. It is very nice to work with.
Like so:
if err == util.ErrLimitReached {
return errHTTPEntityTooLargeAttachmentTooLarge
}
Or so:
if err != nil {
return wrapErrHTTP(errHTTPBadRequestActionsInvalid, err.Error())
}
[1] https://github.com/binwiederhier/ntfy/blob/main/server/server.go#L56 https://github.com/binwiederhier/ntfy/blob/main/server/serve...
[2] https://github.com/binwiederhier/ntfy/blob/main/server/errors.go https://github.com/binwiederhier/ntfy/blob/main/server/error...