You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docs/docs/core/server-errors.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,15 @@ throw new TsRestResponseError(contract.getPost, {
14
14
});
15
15
```
16
16
17
+
You can also pass an entire contract to the `TsRestResponseError` constructor, and it will allow you to pass responses that are common to all endpoints.
18
+
19
+
```typescript
20
+
thrownewTsRestResponseError(contract, {
21
+
status: 404,
22
+
body: { message: 'Not Found' },
23
+
});
24
+
```
25
+
17
26
:::caution
18
27
19
28
Any thrown `TsRestResponseError` will NOT be caught by any error handlers, and will be served as a response straight away.
0 commit comments