mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-18 16:44:32 +00:00
refactor exchange exception
This commit is contained in:
parent
a3b5ba5b04
commit
4cbf8b8cd9
7 changed files with 25 additions and 15 deletions
13
lib/exceptions/exchange/exchange_exception.dart
Normal file
13
lib/exceptions/exchange/exchange_exception.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
import 'package:stackwallet/exceptions/sw_exception.dart';
|
||||
|
||||
enum ExchangeExceptionType { generic, serializeResponseError }
|
||||
|
||||
class ExchangeException extends SWException {
|
||||
ExchangeExceptionType type;
|
||||
ExchangeException(super.message, this.type);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return message;
|
||||
}
|
||||
}
|
5
lib/exceptions/exchange/majestic_bank/mb_exception.dart
Normal file
5
lib/exceptions/exchange/majestic_bank/mb_exception.dart
Normal file
|
@ -0,0 +1,5 @@
|
|||
import 'package:stackwallet/exceptions/exchange/exchange_exception.dart';
|
||||
|
||||
class MBException extends ExchangeException {
|
||||
MBException(super.message, super.type);
|
||||
}
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:stackwallet/exceptions/exchange/exchange_exception.dart';
|
||||
import 'package:stackwallet/external_api_keys.dart';
|
||||
import 'package:stackwallet/models/exchange/change_now/cn_exchange_estimate.dart';
|
||||
import 'package:stackwallet/models/exchange/change_now/estimated_exchange_amount.dart';
|
||||
|
|
|
@ -55,7 +55,7 @@ class ExchangeDataLoadingService {
|
|||
}
|
||||
} else {
|
||||
Logging.instance.log(
|
||||
"Failed to load changeNOW fixed rate markets: ${response3.exception?.errorMessage}",
|
||||
"Failed to load changeNOW fixed rate markets: ${response3.exception?.message}",
|
||||
level: LogLevel.Error);
|
||||
|
||||
ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state =
|
||||
|
@ -122,7 +122,7 @@ class ExchangeDataLoadingService {
|
|||
}
|
||||
} else {
|
||||
Logging.instance.log(
|
||||
"Failed to load changeNOW available floating rate pairs: ${response2.exception?.errorMessage}",
|
||||
"Failed to load changeNOW available floating rate pairs: ${response2.exception?.message}",
|
||||
level: LogLevel.Error);
|
||||
ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state =
|
||||
ChangeNowLoadStatus.failed;
|
||||
|
@ -130,7 +130,7 @@ class ExchangeDataLoadingService {
|
|||
}
|
||||
} else {
|
||||
Logging.instance.log(
|
||||
"Failed to load changeNOW currencies: ${response.exception?.errorMessage}",
|
||||
"Failed to load changeNOW currencies: ${response.exception?.message}",
|
||||
level: LogLevel.Error);
|
||||
await Future<void>.delayed(const Duration(seconds: 3));
|
||||
ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state =
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
enum ExchangeExceptionType { generic, serializeResponseError }
|
||||
|
||||
class ExchangeException implements Exception {
|
||||
String errorMessage;
|
||||
ExchangeExceptionType type;
|
||||
ExchangeException(this.errorMessage, this.type);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
import 'package:stackwallet/exceptions/exchange/exchange_exception.dart';
|
||||
|
||||
class ExchangeResponse<T> {
|
||||
late final T? value;
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||
|
||||
import 'package:decimal/decimal.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:stackwallet/exceptions/exchange/exchange_exception.dart';
|
||||
import 'package:stackwallet/models/exchange/majestic_bank/mb_limit.dart';
|
||||
import 'package:stackwallet/models/exchange/majestic_bank/mb_order.dart';
|
||||
import 'package:stackwallet/models/exchange/majestic_bank/mb_order_calculation.dart';
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
import 'package:decimal/decimal.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:stackwallet/exceptions/exchange/exchange_exception.dart';
|
||||
import 'package:stackwallet/external_api_keys.dart';
|
||||
import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.dart';
|
||||
import 'package:stackwallet/models/exchange/response_objects/pair.dart';
|
||||
|
|
Loading…
Reference in a new issue