err
Package err provides application errors with HTTP status codes (Express-style).
import "github.com/sahilkhaire/gox/err"
Select a symbol below — each page explains what it does, shows Node.js vs Go comparisons, and includes a runnable example.
Functions
| Symbol | Node.js | Kind | Summary |
|---|---|---|---|
| As | — | func | As finds the first error in the chain assignable to target. |
| Is | — | func | Is reports whether err matches target in the error chain. |
Types
| Symbol | Node.js | Kind | Summary |
|---|---|---|---|
| AppError | — | type | AppError is an error with an HTTP status code. |
Methods
| Symbol | Node.js | Kind | Summary |
|---|---|---|---|
| AppError.BadRequest | createError(400, msg) | method | BadRequest returns a 400 AppError. |
| AppError.Forbidden | createError(403, msg) | method | Forbidden returns a 403 AppError. |
| AppError.Internal | createError(500, msg) | method | Internal returns a 500 AppError. |
| AppError.New | — | method | New creates an AppError with code and message. |
| AppError.NotFound | createError(404, msg) | method | NotFound returns a 404 AppError. |
| AppError.Unauthorized | createError(401, msg) | method | Unauthorized returns a 401 AppError. |
| AppError.Wrap | — | method | Wrap wraps cause with code and message. |