findError static method
Finds an error message from the response based on the status code and object type.
If the status code is 401
or 403
and the object is a list of bytes or a string,
it attempts to decode the error message.
Returns: A decoded error message if applicable, otherwise null
.
Implementation
static String? findError({Object? object, required int statusCode}) {
if (statusCode == 401 || statusCode == 403) {
if (object is List<int>) {
return StringUtils.tryDecode(object);
} else if (object is String) {
return object;
}
}
return null;
}