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 {
194194 // --- Other Methods ---
195195 // Methods not allowed on the item endpoint
196196 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 ;
197203 } 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)
202205 print (
203206 'Unexpected error in /data/[id].dart handler: $e \n $stackTrace ' ,
204207 );
Original file line number Diff line number Diff line change @@ -171,13 +171,17 @@ Future<Response> onRequest(RequestContext context) async {
171171 // --- Other Methods ---
172172 // Methods not allowed on the collection endpoint
173173 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 ;
174180 } 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)
178182 print (
179183 'Unexpected error in /data/index.dart handler: $e \n $stackTrace ' ,
180- ); // Log the error and stack trace
184+ );
181185 return Response (
182186 statusCode: HttpStatus .internalServerError,
183187 body: 'Internal Server Error.' ,
You can’t perform that action at this time.
0 commit comments