2023-12-01 12:56:24 +03:30
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2026-01-17 13:09:20 +03:00
|
|
|
import 'package:umbrix/core/localization/translations.dart';
|
|
|
|
|
import 'package:umbrix/core/model/failures.dart';
|
2023-12-01 12:56:24 +03:30
|
|
|
|
|
|
|
|
part 'proxy_failure.freezed.dart';
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
sealed class ProxyFailure with _$ProxyFailure, Failure {
|
|
|
|
|
const ProxyFailure._();
|
|
|
|
|
|
|
|
|
|
@With<UnexpectedFailure>()
|
|
|
|
|
const factory ProxyFailure.unexpected([
|
|
|
|
|
Object? error,
|
|
|
|
|
StackTrace? stackTrace,
|
|
|
|
|
]) = ProxyUnexpectedFailure;
|
|
|
|
|
|
|
|
|
|
@With<ExpectedFailure>()
|
|
|
|
|
const factory ProxyFailure.serviceNotRunning() = ServiceNotRunning;
|
|
|
|
|
|
2024-02-17 13:11:50 +03:30
|
|
|
@With<ExpectedFailure>()
|
|
|
|
|
const factory ProxyFailure.unknownIp() = UnknownIp;
|
|
|
|
|
|
2024-02-20 18:49:30 +03:30
|
|
|
@With<ExpectedMeasuredFailure>()
|
|
|
|
|
const factory ProxyFailure.unableToRetrieveIp([
|
|
|
|
|
Object? error,
|
|
|
|
|
StackTrace? stackTrace,
|
|
|
|
|
]) = UnableToRetrieveIp;
|
|
|
|
|
|
2023-12-01 12:56:24 +03:30
|
|
|
@override
|
|
|
|
|
({String type, String? message}) present(TranslationsEn t) {
|
|
|
|
|
return switch (this) {
|
|
|
|
|
ProxyUnexpectedFailure() => (
|
|
|
|
|
type: t.failure.unexpected,
|
|
|
|
|
message: null,
|
|
|
|
|
),
|
|
|
|
|
ServiceNotRunning() => (
|
|
|
|
|
type: t.failure.singbox.serviceNotRunning,
|
|
|
|
|
message: null,
|
|
|
|
|
),
|
2024-02-17 13:11:50 +03:30
|
|
|
UnknownIp() => (type: t.general.unknown, message: null),
|
2024-02-20 18:49:30 +03:30
|
|
|
UnableToRetrieveIp() => (
|
|
|
|
|
type: t.failure.unexpected,
|
|
|
|
|
message: null,
|
|
|
|
|
),
|
2023-12-01 12:56:24 +03:30
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|