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: docs/features/event-handler/rest.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,6 +148,8 @@ You can use the `errorHandler()` method as a higher-order function or class meth
148
148
149
149
This allows you to catch and return custom error responses, or perform any other error handling logic you need.
150
150
151
+
Error handlers receive the error object and the request context as arguments, and can return a [`Response` object](#returning-response-objects) or a JavaScript object that will be auto-serialized as per the [response auto-serialization](#response-auto-serialization) section.
152
+
151
153
!!! tip "You can also pass a list of error classes to the `errorHandler()` method."
152
154
153
155
=== "index.ts"
@@ -158,15 +160,17 @@ This allows you to catch and return custom error responses, or perform any other
158
160
159
161
### Throwing HTTP errors
160
162
161
-
You can throw HTTP errors in your route handlers to return specific HTTP status codes and messages. Event Handler provides a set of built-in HTTP error classes that you can use to throw common HTTP errors.
163
+
You can throw HTTP errors in your route handlers to stop execution and return specific HTTP status codes and messages. Event Handler provides a set of built-in HTTP error classes that you can use to throw common HTTP errors.
162
164
163
165
This ensures that your Lambda function doesn't fail but returns a well-defined HTTP error response to the client.
164
166
165
167
If you need to send custom headers or a different response structure/code, you can use the [Response](#returning-response-objects) object instead.
166
168
169
+
!!! tip "You can throw HTTP errors in your route handlers, middleware, or custom error handlers!"
0 commit comments