public static void handleRequestError(final Response response) {
    if (response.getBody() == null) {
      throw new StitchServiceException(
          String.format(
              Locale.ENGLISH, "received unexpected status code %d", response.getStatusCode()),
          StitchServiceErrorCode.UNKNOWN);
    }

    final String body;
    try {
      body = readAllToString(response.getBody());
    } catch (final Exception e) {
      throw new StitchServiceException(
          String.format(
              Locale.ENGLISH, "received unexpected status code %d", response.getStatusCode()),
          StitchServiceErrorCode.UNKNOWN);
    }

    final String errorMsg = handleRichError(response, body);
    throw new StitchServiceException(errorMsg, StitchServiceErrorCode.UNKNOWN);
  }
public static void handleRequestError ( final Response response ) { if ( response . getBody ( ) == null ) { throw new StitchServiceException ( String . format ( Locale . ENGLISH , "received unexpected status code %d" , response . getStatusCode ( ) ) , StitchServiceErrorCode . UNKNOWN ) ; } final String body ; try { body = readAllToString ( response . getBody ( ) ) ; } catch ( final Exception e ) { throw new StitchServiceException ( String . format ( Locale . ENGLISH , "received unexpected status code %d" , response . getStatusCode ( ) ) , StitchServiceErrorCode . UNKNOWN ) ; } final String errorMsg = handleRichError ( response , body ) ; throw new StitchServiceException ( errorMsg , StitchServiceErrorCode . UNKNOWN ) ; }
Static utility method that accepts an HTTP response object, and throws the {@link
StitchServiceException} representing the the error in the response. If the error cannot be
recognized, this will throw a {@link StitchServiceException} with the "UNKNOWN" error code.

@param response the network response.