FailureMapper2 class final

Расширяемый маппер ошибок в Failure с поддержкой DI.

В отличие от FailureMapper, поддерживает регистрацию кастомных мапперов через DI (get_it, injectable) и позволяет переупорядочить мапперы.

Порядок маппинга

  1. Если error уже является Failure — возвращается как есть.
  2. Кастомные мапперы приложения (регистрируются через DI, высший приоритет).
  3. Встроенные мапперы nexo (порядок фиксирован).
  4. Catch-all → Failure.unknown.

Пример использования

// Регистрация через DI
@Singleton(as: FailureMapper2)
class AppFailureMapper extends FailureMapper2 {
  AppFailureMapper() : super(
    extraMappers: [
      const AdminApiFailureMapper(),
      const ServerpodFailureMapper(),
    ],
  );
}

// Использование
final failure = getIt<FailureMapper2>().from(error, stackTrace);

См. также: FailureMapper, FailureSubMapper.

Constructors

FailureMapper2({List<FailureSubMapper>? extraMappers})
Создаёт экземпляр FailureMapper2.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

from(Object error, [StackTrace? stackTrace]) → Failure
Преобразует произвольный error в Failure.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(FailureSubMapper mapper) → void
Регистрирует кастомный маппер (высший приоритет).
registerAll(List<FailureSubMapper> mappers) → void
Регистрирует список мапперов.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fromStatic(Object error, [StackTrace? stackTrace]) → Failure
Статический метод для обратной совместимости.