RootSoft / algorand-dart

Unofficial community SDK to interact with the Algorand network, for Dart & Flutter
MIT License
36 stars 16 forks source link

Show algod error #13

Closed 2i2i closed 2 years ago

2i2i commented 2 years ago

E.g. in src/repositories/transaction_repository.dart -> sendTransaction or sendTransactions -> on DioError catch (ex):

There is a message from algod in ex.response.data. Would be helpful to either print this or make it part of the AlgorandException.

RootSoft commented 2 years ago

You can always get the underlying exception using the included cause object of AlgorandException. I might add a new property to include the api error message as well.

try {
  ...
} on AlgorandException catch (ex) {
  final cause = ex.cause;
  if (cause is DioError) {
    print(cause.response?.data['message']);
  }
}
2i2i commented 2 years ago

You are right. I just could not figure out how to cast the Object? cause to a DioError (i am new to dart). I will close the issue.