I am trying out a error handling method in a web app that I am creating. The SomeVariable var can be called by multiple failing requests with different errors. The message will be sent to the end user with the specified response code, and the error will be logged. I am planning to create multiple variables with appropriate messages and response codes.
type SomeStruct struct { e error message string httpCode int } func (s *SomeStruct) Error() string { return e.Err() } type SomeType func(err error) *SomeStruct var SomeVariable SomeType = func(err error) *SomeStruct { return &SomeStruct{ e: err, message: "something went wrong", httpCode: 500, } }