stack_wallet/lib/services/buy/buy_response.dart

29 lines
503 B
Dart
Raw Normal View History

enum BuyExceptionType {
generic,
serializeResponseError,
cryptoAmountOutOfRange,
}
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-14 14:21:32 +00:00
final T? value;
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}";
}
}