From 5746d031b9f9e0474b01508396e005c8ca2388db Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 28 Oct 2022 11:48:40 +0700 Subject: [PATCH] TF-1115 Add `CacheExceptionThrower` --- lib/main/exceptions/cache_exception.dart | 16 ++++++++++++++++ lib/main/exceptions/cache_exception_thrower.dart | 10 ++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lib/main/exceptions/cache_exception.dart create mode 100644 lib/main/exceptions/cache_exception_thrower.dart diff --git a/lib/main/exceptions/cache_exception.dart b/lib/main/exceptions/cache_exception.dart new file mode 100644 index 000000000..cf83c56a4 --- /dev/null +++ b/lib/main/exceptions/cache_exception.dart @@ -0,0 +1,16 @@ + +import 'package:equatable/equatable.dart'; + +abstract class CacheException with EquatableMixin implements Exception { + + final String? message; + + const CacheException({this.message}); +} + +class UnknownCacheError extends CacheException { + const UnknownCacheError({String? message}) : super(message: message); + + @override + List get props => []; +} \ No newline at end of file diff --git a/lib/main/exceptions/cache_exception_thrower.dart b/lib/main/exceptions/cache_exception_thrower.dart new file mode 100644 index 000000000..1e823710c --- /dev/null +++ b/lib/main/exceptions/cache_exception_thrower.dart @@ -0,0 +1,10 @@ +import 'package:tmail_ui_user/main/exceptions/cache_exception.dart'; +import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; + +class CacheExceptionThrower extends ExceptionThrower { + + @override + void throwException(dynamic exception) { + throw UnknownCacheError(message: exception.toString()); + } +} \ No newline at end of file