Skip to content

Commit 6adcf5e

Browse files
committed
Recommend errors.As instead of type assertion.
1 parent 1fe7d23 commit 6adcf5e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

website/docs/guide/error-handling.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ func customHTTPErrorHandler(err error, c echo.Context) {
7171
}
7272

7373
code := http.StatusInternalServerError
74-
if he, ok := err.(*echo.HTTPError); ok {
74+
var he *echo.HTTPError
75+
if errors.As(err, &he) {
7576
code = he.Code
7677
}
7778
c.Logger().Error(err)

0 commit comments

Comments
 (0)