instead of checking if it's a List, check if it's not a Map

This commit is contained in:
sneurlax 2024-02-06 12:31:42 -06:00
parent 53931eda32
commit 15a9543c9f

View file

@ -748,27 +748,25 @@ class ElectrumXClient {
return {"rawtx": response["result"] as String}; return {"rawtx": response["result"] as String};
} }
if (response is List) { if (response is! Map) {
Logging.instance.log( final String msg = "getTransaction($txHash) returned a non-Map response"
"getTransaction($txHash) returned null response", " of type ${response.runtimeType}.";
level: LogLevel.Error, Logging.instance.log(msg, level: LogLevel.Fatal);
); throw Exception(msg);
throw 'getTransaction($txHash) returned null response';
} else {
if (response["result"] == null) {
Logging.instance.log(
"getTransaction($txHash) returned null response",
level: LogLevel.Error,
);
throw 'getTransaction($txHash) returned null response';
}
return Map<String, dynamic>.from(response["result"] as Map);
} }
} catch (e) {
if (response["result"] == null) {
final String msg = "getTransaction($txHash) returned null result."
"\nResponse: $response";
Logging.instance.log(msg, level: LogLevel.Fatal);
throw Exception(msg);
}
return Map<String, dynamic>.from(response["result"] as Map);
} catch (e, s) {
Logging.instance.log( Logging.instance.log(
"getTransaction($txHash) response: $response", "getTransaction($txHash) response: $response"
level: LogLevel.Error, "\nError: $e\nStack trace: $s",
); level: LogLevel.Error);
rethrow; rethrow;
} }
} }