Skip to content

Commit

Permalink
docs: add explanation about non-standard status code usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaidev committed May 30, 2024
1 parent 30bdb3c commit 85bbca5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ import { HttpError } from "@mrcaidev/http-errors";
throw new HttpError(400, "Malformed data"); // status: 400, message: "Malformed data"
```

Dynamic non-standard status code:

```ts
import { HttpError } from "@mrcaidev/http-errors";

throw new HttpError(499); // status: 499, message: "Unknown"
```

Dynamic non-standard status code and custom error message:

```ts
import { HttpError } from "@mrcaidev/http-errors";

throw new HttpError(499, "Custom error"); // status: 400, message: "Custom error"
```

Every error class extends `HttpError`, which further extends `Error`.

```ts
Expand Down

0 comments on commit 85bbca5

Please sign in to comment.