From f0d678da676a6dd40207987f4bf079e8c221a89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Werner?= Date: Thu, 20 Apr 2023 14:58:40 +0200 Subject: [PATCH] improve error handling for net error(s) fixes: reverse proxy support #2419 --- docs/guide/error-handling.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/guide/error-handling.md b/docs/guide/error-handling.md index 7d3aa361a9..ae596848c7 100644 --- a/docs/guide/error-handling.md +++ b/docs/guide/error-handling.md @@ -71,6 +71,12 @@ Fiber provides an error handler by default. For a standard error, the response i ```go title="Example" // Default error handler var DefaultErrorHandler = func(c *fiber.Ctx, err error) error { + // Handle internal network errors + var netError net.Error + if errors.As(err, &netError) { + // 502 - Bad Gateway + err = ErrBadGateway + } // Status code defaults to 500 code := fiber.StatusInternalServerError