Files
umbrix/lib/features/geo_asset/model/geo_asset_failure.dart
problematicconsumer ed614988a2 Refactor
2023-12-01 12:56:24 +03:30

42 lines
1.2 KiB
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/core/model/failures.dart';
part 'geo_asset_failure.freezed.dart';
@freezed
sealed class GeoAssetFailure with _$GeoAssetFailure, Failure {
const GeoAssetFailure._();
@With<UnexpectedFailure>()
const factory GeoAssetFailure.unexpected([
Object? error,
StackTrace? stackTrace,
]) = GeoAssetUnexpectedFailure;
@With<ExpectedFailure>()
const factory GeoAssetFailure.noUpdateAvailable() = GeoAssetNoUpdateAvailable;
@With<ExpectedMeasuredFailure>()
const factory GeoAssetFailure.activeAssetNotFound() =
GeoAssetActiveAssetNotFound;
@override
({String type, String? message}) present(TranslationsEn t) {
return switch (this) {
GeoAssetUnexpectedFailure() => (
type: t.failure.geoAssets.unexpected,
message: null,
),
GeoAssetNoUpdateAvailable() => (
type: t.failure.geoAssets.notUpdate,
message: null
),
GeoAssetActiveAssetNotFound() => (
type: t.failure.geoAssets.activeNotFound,
message: null,
),
};
}
}