3 ms·
Hah, this is very similar to the one I use within my apps. type AppError struct { Code int Message string InternalMessage s
by oolongCat 10y ago
Hah, this is very similar to the one I use within my apps.
type AppError struct {
Code int
Message string
InternalMessage string
Time time.Time
HttpCode int
}
All my errors are handled in a http handler function. Before that these errors are produced in any functions called by my handler functions.
I concatenate in to the InternalMessage var any error message I want to log, basically anything I want to show an admin.
The message tag will have anything I want to show a user. Normally separated by a semicolon.
Because of this I can give good errors to my users, and I have enough information when something goes wrong.
The only negative might be that, the internal error logs are a bit verbose.
- oolongCat 10y agooops. My Bad the code above should be type AppError struct { Code int Message string InternalMessage string Time time.Time HttpCode int }