Skip to content

feat: Return convenient errors to middlewares #1684

Description

@Rilord

Context

For *requests_total Counter metric we need to track HTTP response status code and operation name inside middleware.

With convenient_errors: true (or "on") is enabled, ogen provides convenient way to map errors to status codes, however the problem is that these status-code-aware errors do not seem to be returned to the middleware chain .

Current Behavior

...
resp, err := next(req) 
...

err = errors.New("not found")

nothing can be done here.

Expected

...
resp, err := next(req) 
...

err = ConvenientErrorWithStatusCode{
  StatusCode: 404,
...
}

using errors.As it's possible to extract status code from the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions