From 8cf5bc86651acffe9bf5b80bffcbb3760dd199f2 Mon Sep 17 00:00:00 2001 From: Dillon Nys Date: Wed, 7 Feb 2024 16:09:09 -0800 Subject: [PATCH] chore(core): Make `SerializationException` implement `BadRequestException` When thrown on the server, a serialization exception means that the server received bad data from the client. --- packages/celest_core/CHANGELOG.md | 2 ++ packages/celest_core/lib/src/exception/cloud_exception.dart | 4 ++-- .../lib/src/exception/serialization_exception.dart | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/celest_core/CHANGELOG.md b/packages/celest_core/CHANGELOG.md index 8cbd31e5..a6e852d8 100644 --- a/packages/celest_core/CHANGELOG.md +++ b/packages/celest_core/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.2.0-dev +- Make `SerializationException` implement `BadRequestException` + ## 0.1.1 - Update README diff --git a/packages/celest_core/lib/src/exception/cloud_exception.dart b/packages/celest_core/lib/src/exception/cloud_exception.dart index 870ec6d8..84e4082f 100644 --- a/packages/celest_core/lib/src/exception/cloud_exception.dart +++ b/packages/celest_core/lib/src/exception/cloud_exception.dart @@ -7,7 +7,7 @@ sealed class CloudException implements CelestException {} /// An exception thrown by a Cloud Function when a request contains invalid /// data or otherwise lead to a recoverable exception. /// {@endtemplate} -final class BadRequestException implements CloudException { +class BadRequestException implements CloudException { /// Creates a [BadRequestException] with the given [message]. /// /// {@macro celest_core_exception_bad_request_exception} @@ -21,7 +21,7 @@ final class BadRequestException implements CloudException { /// An exception thrown by a Cloud Function when an unrecoverable internal error /// occurs. /// {@endtemplate} -final class InternalServerException implements CloudException { +class InternalServerException implements CloudException { /// Creates a [InternalServerException] with the given [message]. /// /// {@macro celest_core_exception_internal_server_exception} diff --git a/packages/celest_core/lib/src/exception/serialization_exception.dart b/packages/celest_core/lib/src/exception/serialization_exception.dart index 2ed31f48..ffb40203 100644 --- a/packages/celest_core/lib/src/exception/serialization_exception.dart +++ b/packages/celest_core/lib/src/exception/serialization_exception.dart @@ -7,7 +7,7 @@ import 'package:celest_core/celest_core.dart'; /// deserialize a value. /// {@endtemplate} final class SerializationException extends FormatException - implements CelestException { + implements BadRequestException, CelestException { /// Creates a [SerializationException] with the given [message]. /// /// {@macro celest_core_exceptions_serialization_exception}