Skip to content

Commit

Permalink
Merge pull request #582 from nunoo/nunoo-NewErrorWithContext
Browse files Browse the repository at this point in the history
add NewErrorWithContext
  • Loading branch information
danielgtaylor authored Sep 20, 2024
2 parents 69d32c3 + d13b066 commit a3a24c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,15 @@ var NewError = func(status int, msg string, errs ...error) StatusError {
}
}

var NewErrorWithContext = func(_ Context, status int, msg string, errs ...error) StatusError {
return NewError(status, msg, errs...)
}

// WriteErr writes an error response with the given context, using the
// configured error type and with the given status code and message. It is
// marshaled using the API's content negotiation methods.
func WriteErr(api API, ctx Context, status int, msg string, errs ...error) error {
var err = NewError(status, msg, errs...)
var err = NewErrorWithContext(ctx, status, msg, errs...)

// NewError may have modified the status code, so update it here if needed.
// If it was not modified then this is a no-op.
Expand Down

0 comments on commit a3a24c7

Please sign in to comment.