findErrorDetails static method
Extracts detailed error information from the response.
Similar to findError, but includes additional details such as JSON parsing.
Returns: A map containing the status code and an error message (if any).
Implementation
static Map<String, dynamic> findErrorDetails(
{Object? object, required int statusCode}) {
String? error;
if (statusCode == 401 || statusCode == 403) {
if (object is List<int>) {
error = StringUtils.tryDecode(object);
} else if (object is String) {
error = object;
} else if (object is Map) {
error = StringUtils.tryFromJson(object);
}
}
return {"statusCode": statusCode, if (error != null) "error": error};
}