bodyOrThrow property

BodyType get bodyOrThrow

Returns the response body if Response isSuccessful and body is not null. Otherwise it throws an HttpException with the response status code and error object. If the error object is an Exception, it will be thrown instead.

Implementation

BodyType get bodyOrThrow {
  if (isSuccessful && body != null) {
    return body!;
  } else {
    if (error is Exception) {
      throw error!;
    }
    throw ChopperHttpException(this);
  }
}