getEffectiveStatusCode returns the actual status code, considering both the error and response status
(c fiber.Ctx, err error)
| 31 | |
| 32 | // getEffectiveStatusCode returns the actual status code, considering both the error and response status |
| 33 | func getEffectiveStatusCode(c fiber.Ctx, err error) int { |
| 34 | if nilerror.IsNil(err) { |
| 35 | return c.Response().StatusCode() |
| 36 | } |
| 37 | |
| 38 | // If there's an error and it's a *fiber.Error, use its status code |
| 39 | var fiberErr *fiber.Error |
| 40 | if errors.As(err, &fiberErr) && fiberErr != nil { |
| 41 | return fiberErr.Code |
| 42 | } |
| 43 | |
| 44 | // Otherwise, use the response status code |
| 45 | return c.Response().StatusCode() |
| 46 | } |