Start renaming
This commit is contained in:
@@ -21,7 +21,7 @@ Fresh supports two kind of error pages:
|
||||
To add an error page use [`app.onError()`](/docs/concepts/app#onerror).
|
||||
|
||||
```ts main.ts
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.onError("*", (ctx) => {
|
||||
@@ -77,13 +77,13 @@ If you need to bail out of execution and need to respond with a particular HTTP
|
||||
error code, you can use Fresh's `HttpError` class:
|
||||
|
||||
```ts
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
```
|
||||
|
||||
`HttpError` takes a status code and an optional message:
|
||||
|
||||
```ts middleware/auth.ts
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
|
||||
async function authMiddleware(ctx) {
|
||||
const user = ctx.state.user;
|
||||
@@ -106,7 +106,7 @@ When an `HttpError` is thrown, Fresh catches it and invokes the error handler.
|
||||
You can check the status code in your error handler:
|
||||
|
||||
```ts
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
|
||||
app.onError("*", (ctx) => {
|
||||
if (ctx.error instanceof HttpError) {
|
||||
|
||||
Reference in New Issue
Block a user