DomainExceptionFailureMapper class final
Маппер доменных исключений AppException в соответствующие Failure.
Преобразует все типы AppException (Auth, Validation, Storage, Database,
Cache, Parse, Permission, Platform, File, Location, Notification, Payment,
Sync) в их функциональные аналоги Failure. Используется для перевода
исключений доменного слоя в унифицированную модель ошибок.
Поддерживает кастомные маппинги через extraMappings — позволяет расширять маппер без модификации исходного кода.
Пример использования
// Стандартный маппер
const mapper = DomainExceptionFailureMapper();
// С кастомными маппингами
const mapper = DomainExceptionFailureMapper(
extraMappings: {
AdminApiException: (error) => Failure.http(
type: HttpFailure.internalServerError,
message: (error as AdminApiException).message,
),
},
);
См. также: AppException, FailureSubMapper.
- Implemented types
Constructors
-
DomainExceptionFailureMapper({Map<
Type, Failure Function(Object)> ? extraMappings}) -
Создаёт маппер доменных исключений.
const
Properties
-
extraMappings
→ Map<
Type, Failure Function(Object)> -
Дополнительные маппинги: тип исключения → функция маппинга.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
tryMap(
Object error, [StackTrace? stackTrace]) → Failure? -
Пытается преобразовать
errorв Failure, если этоAppException.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited