Pass parameters from handler to NewError function? #1403
Unanswered
oliverdding
asked this question in
Q&A
Replies: 1 comment
-
Found a terrible solution: func (service *CAPIService) HealthCheck(ctx context.Context, params gen.HealthCheckParams) (*gen.HealthCheckOutputBodyHeaders, error) {
output, err := service.HealthCheckWrap(ctx, params)
if err != nil {
err = fmt.Errorf("timeout when pinging the database: %w", errors.New("My Variable"))
}
return output, err
}
func (service *CAPIService) HealthCheckWrap(ctx context.Context, params gen.HealthCheckParams) (*gen.HealthCheckOutputBodyHeaders, error) {
... // real logic
}
func (service *CAPIService) NewError(ctx context.Context, err error) *gen.ErrorOutputBodyStatusCodeWithHeaders {
MY_VAR := errors.Unwrap(err)
...
} I think the library should expose a method to query the request. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I a some parameters from the request header, and want to return it in the response body whether the handler encountered error or not. But the NewError function generated do not accept another parameters but the
error
. How to do that?Beta Was this translation helpful? Give feedback.
All reactions