File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -194,11 +194,14 @@ Future<Response> onRequest(RequestContext context, String id) async {
194
194
// --- Other Methods ---
195
195
// Methods not allowed on the item endpoint
196
196
return Response (statusCode: HttpStatus .methodNotAllowed);
197
+ } on HtHttpException catch (_) {
198
+ // Let the errorHandler middleware handle HtHttpExceptions (incl. NotFound)
199
+ rethrow ;
200
+ } on FormatException catch (_) {
201
+ // Let the errorHandler middleware handle FormatExceptions (e.g., from PUT body)
202
+ rethrow ;
197
203
} catch (e, stackTrace) {
198
- // Catch any other unexpected errors (e.g., provider resolution, etc.)
199
- // Specific HtHttpException (including NotFoundException), FormatException,
200
- // and TypeError should be caught by the central errorHandler middleware
201
- // or handled specifically within the PUT/POST logic for request body validation.
204
+ // Handle any other unexpected errors locally (e.g., provider resolution)
202
205
print (
203
206
'Unexpected error in /data/[id].dart handler: $e \n $stackTrace ' ,
204
207
);
Original file line number Diff line number Diff line change @@ -171,13 +171,17 @@ Future<Response> onRequest(RequestContext context) async {
171
171
// --- Other Methods ---
172
172
// Methods not allowed on the collection endpoint
173
173
return Response (statusCode: HttpStatus .methodNotAllowed);
174
+ } on HtHttpException catch (_) {
175
+ // Let the errorHandler middleware handle HtHttpExceptions
176
+ rethrow ;
177
+ } on FormatException catch (_) {
178
+ // Let the errorHandler middleware handle FormatExceptions
179
+ rethrow ;
174
180
} catch (e, stackTrace) {
175
- // Catch any other unexpected errors (e.g., provider resolution, etc.)
176
- // Specific HtHttpException and FormatException should be caught by
177
- // the central errorHandler middleware.
181
+ // Handle any other unexpected errors locally (e.g., provider resolution)
178
182
print (
179
183
'Unexpected error in /data/index.dart handler: $e \n $stackTrace ' ,
180
- ); // Log the error and stack trace
184
+ );
181
185
return Response (
182
186
statusCode: HttpStatus .internalServerError,
183
187
body: 'Internal Server Error.' ,
You can’t perform that action at this time.
0 commit comments