stack_wallet/lib/services/buy/buy_response.dart

25 lines
482 B
Dart
Raw Normal View History

2023-01-11 23:02:57 +00:00
enum BuyExceptionType { generic, serializeResponseError }
2023-01-11 15:54:39 +00:00
2023-01-11 23:02:57 +00:00
class BuyException implements Exception {
2023-01-11 15:54:39 +00:00
String errorMessage;
2023-01-11 23:02:57 +00:00
BuyExceptionType type;
BuyException(this.errorMessage, this.type);
2023-01-11 15:54:39 +00:00
@override
String toString() {
return errorMessage;
}
}
2023-01-11 23:02:57 +00:00
class BuyResponse<T> {
2023-01-11 15:54:39 +00:00
late final T? value;
2023-01-11 23:02:57 +00:00
late final BuyException? exception;
2023-01-11 15:54:39 +00:00
2023-01-11 23:02:57 +00:00
BuyResponse({this.value, this.exception});
2023-01-11 15:54:39 +00:00
@override
String toString() {
return "{error: $exception, value: $value}";
}
}