diff --git a/packages/celest/lib/src/runtime/serve.dart b/packages/celest/lib/src/runtime/serve.dart index 92dd1712..737bd89d 100644 --- a/packages/celest/lib/src/runtime/serve.dart +++ b/packages/celest/lib/src/runtime/serve.dart @@ -121,18 +121,6 @@ Handler _cloudExceptionMiddleware(Handler inner) { return (request) async { try { return await inner(request); - } on BadRequestException catch (e) { - print('Bad request: ${e.message}'); - return _badRequest( - code: 'BadRequestException', - details: Serializers.instance.serialize(e), - ); - } on InternalServerException catch (e) { - print('Internal server error: ${e.message}'); - return _internalServerError( - code: 'InternalServerException', - details: Serializers.instance.serialize(e), - ); } on Exception catch (e, st) { print('An unexpected error occurred: $e'); print(st); diff --git a/packages/celest_core/lib/src/exception/serialization_exception.dart b/packages/celest_core/lib/src/exception/serialization_exception.dart index ffb40203..9b69f5e0 100644 --- a/packages/celest_core/lib/src/exception/serialization_exception.dart +++ b/packages/celest_core/lib/src/exception/serialization_exception.dart @@ -13,6 +13,11 @@ final class SerializationException extends FormatException /// {@macro celest_core_exceptions_serialization_exception} const SerializationException(super.message); + @override + // TODO(dnys1): Find a better resolution to this. + // ignore: overridden_fields + final Null source = null; + @override String toString() => 'SerializationException: $message'; } diff --git a/packages/celest_core/lib/src/serialization/serializer.dart b/packages/celest_core/lib/src/serialization/serializer.dart index 558151da..d863fda6 100644 --- a/packages/celest_core/lib/src/serialization/serializer.dart +++ b/packages/celest_core/lib/src/serialization/serializer.dart @@ -3,7 +3,6 @@ import 'dart:typed_data'; import 'package:celest_core/celest_core.dart'; import 'package:celest_core/src/serialization/serializers/big_int_serializer.dart'; -import 'package:celest_core/src/serialization/serializers/cloud_exception_serializer.dart'; import 'package:celest_core/src/serialization/serializers/date_time_serializer.dart'; import 'package:celest_core/src/serialization/serializers/duration_serializer.dart'; import 'package:celest_core/src/serialization/serializers/regexp_serializer.dart'; @@ -101,8 +100,6 @@ final class _Serializers extends Serializers { put(const UriSerializer()); put(const UriDataSerializer()); put(const Uint8ListSerializer()); - put(const BadRequestExceptionSerializer()); - put(const InternalServerExceptionSerializer()); } final _serializersByType = , Serializer>{}; diff --git a/packages/celest_core/lib/src/serialization/serializers/cloud_exception_serializer.dart b/packages/celest_core/lib/src/serialization/serializers/cloud_exception_serializer.dart deleted file mode 100644 index bf410c89..00000000 --- a/packages/celest_core/lib/src/serialization/serializers/cloud_exception_serializer.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:celest_core/celest_core.dart'; - -/// A [Serializer] for [BadRequestException] objects. -final class BadRequestExceptionSerializer - extends Serializer { - /// Creates a [Serializer] for [BadRequestException] objects. - const BadRequestExceptionSerializer(); - - @override - BadRequestException deserialize(Object? value) { - final body = assertWireType>(value); - return BadRequestException( - (body[r'message'] as String), - ); - } - - @override - Map serialize(BadRequestException value) { - return { - 'message': value.message, - }; - } -} - -/// A [Serializer] for [InternalServerException] objects. -final class InternalServerExceptionSerializer - extends Serializer { - /// Creates a [Serializer] for [InternalServerException] objects. - const InternalServerExceptionSerializer(); - - @override - InternalServerException deserialize(Object? value) { - final body = assertWireType>(value); - return InternalServerException( - (body[r'message'] as String), - ); - } - - @override - Map serialize(InternalServerException value) { - return { - 'message': value.message, - }; - } -}