handleErrorMessage static method

dynamic handleErrorMessage(
  1. Response response
)

Implementation

static handleErrorMessage(Response response) {
  if (response.statusCode != 200 && response.statusCode != 204) {
    try {
      throw ErrorResponseException.fromJson(json.decode(response.body));
    }
    on ErrorResponseException catch(e) {
      rethrow;
    }
    catch (e) {
      throw ErrorResponseException.fromJson({
        'code': response.statusCode.toString(),
        'message': response.reasonPhrase,
      });
    }
  }
}