Skip to content

Double running of echo.HTTPErrorHandler #15

@rattuscz

Description

@rattuscz

I'm experiencing double calling of HTTPErrorHandler by lecho middleware logger.

First it's called if there was error during request processing, immediately when request is returned from middleware chain:

lecho/middleware.go

Lines 84 to 86 in 6b6fa8f

if err = next(c); err != nil {
c.Error(err)
}

Next request log is produced and sent, but the middleware returns the same error again up:

return err

This causes the error to be propagated up the chain and is again sent to HTTPErrorHandler function by echo itself:
https://github.com/labstack/echo/blob/4a1ccdfdc520eb90573a97a7d04fd9fc300c1629/echo.go#L619-L631

The "native" echo Logger middleware does not do this, the error is consumed by calling handler immediately (the same as lecho) and then error sent up the middleware chain is actual result (error) of writing the log.

Do I understand something wrongly (ie is this expected behavior and i'm supposed to somehow catch the error) or is this actual bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions