getExceptionForResponse method

ApiException getExceptionForResponse(
  1. Response response
)

Generate appropriate ApiException from http response.

Implementation

ApiException getExceptionForResponse(http.Response response) {
  ApiExceptionType exceptionType =
      responseCodeExceptionMapping[response.statusCode] ??
          ApiExceptionType.UNKNOWN;

  print(
      "Request error: Body: ${response.body}, Code: ${response.statusCode}");
  return ApiException(
      type: exceptionType,
      statusCode: response.statusCode,
      message: response.body);
}