Files
umbrix/lib/domain/rules/geo_asset_failure.dart

40 lines
1.1 KiB
Dart
Raw Normal View History

2023-11-17 21:30:09 +03:30
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hiddify/core/prefs/prefs.dart';
import 'package:hiddify/domain/failures.dart';
part 'geo_asset_failure.freezed.dart';
@freezed
sealed class GeoAssetFailure with _$GeoAssetFailure, Failure {
const GeoAssetFailure._();
const factory GeoAssetFailure.unexpected([
Object? error,
StackTrace? stackTrace,
]) = GeoAssetUnexpectedFailure;
@With<ExpectedFailure>()
const factory GeoAssetFailure.noUpdateAvailable() = GeoAssetNoUpdateAvailable;
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,
),
};
}
}