Source:
<code>public Exception decode(String methodKey, Response response) { Collection<String> contentType = response.headers().get(HttpHeaders.CONTENT_TYPE); if (contentType == null) { contentType = ImmutableSet.of(); } Body body = response.body(); if (body != null) { if (contentType.contains(MediaType.APPLICATION_JSON)) { String bodyAsString = readBodyAsString(body); try { SerializableError error = MAPPER.readValue(bodyAsString, SerializableError.class); Class<? extends Exception> exceptionClass = error.getExceptionClass(); Exception remoteException = exceptionClass.getConstructor(String.class).newInstance(error.getMessage()); List<StackTraceElement> stackTrace = error.getStackTrace(); if (stackTrace != null) { remoteException.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()])); } Constructor<? extends Exception> constructor; try { constructor = exceptionClass.getConstructor(String.class, Throwable.class); } catch (NoSuchMethodException e) { constructor = exceptionClass.getConstructor(String.class); } <START> Exception localException = constructor.newInstance(error.getMessage(), remoteException); <END> localException.fillInStackTrace(); localException.setStackTrace(new RuntimeException().getStackTrace()); return localException; } catch (Exception e) { log.error("Failed to parse error body as GenericError.", e); String message = String.format("Error %s. Reason: %s. Failed to parse error body: %s. Body:%n%s", response.status(), response.reason(), e.getMessage(), bodyAsString); return new RuntimeException(message); } } else if (contentType.contains(MediaType.TEXT_HTML) || contentType.contains(MediaType.TEXT_PLAIN) || contentType.contains(MediaType.TEXT_XML)) { String bodyAsString = readBodyAsString(body); String message = String.format("Error %s. Reason: %s. Body:%n%s", response.status(), response.reason(), bodyAsString); return new RuntimeException(message); } String message = String.format("Error %s. Reason: %s. Body content type: %s", response.status(), response.reason(), contentType); return new RuntimeException(message); } else { return new RuntimeException(String.format("%s %s", response.status(), response.reason())); } }</code><technical_language>this break exception classes String (String, Throwable)</technical_language>

Target:
public Exception decode(String methodKey, Response response) { Collection<String> contentType = response.headers().get(HttpHeaders.CONTENT_TYPE); if (contentType == null) { contentType = ImmutableSet.of(); } Body body = response.body(); if (body != null) { if (contentType.contains(MediaType.APPLICATION_JSON)) { String bodyAsString = readBodyAsString(body); SerializableError error; try { error = MAPPER.readValue(bodyAsString, SerializableError.class); } catch (Exception e) { log.error("Failed to parse error body as SerializableError.", e); String message = String.format( "Error %s. Reason: %s. Failed to parse error body and instantiate exception: %s. Body:%n%s", response.status(), response.reason(), e.getMessage(), bodyAsString); return new RuntimeException(message); } Exception remoteException = constructException(error.getExceptionClass(), error.getMessage()); List<StackTraceElement> stackTrace = error.getStackTrace(); if (stackTrace != null) { remoteException.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()])); } Exception localException = constructException(error.getExceptionClass(), error.getMessage(), remoteException); localException.fillInStackTrace(); return localException; } else if (contentType.contains(MediaType.TEXT_HTML) || contentType.contains(MediaType.TEXT_PLAIN) || contentType.contains(MediaType.TEXT_XML)) { String bodyAsString = readBodyAsString(body); String message = String.format("Error %s. Reason: %s. Body:%n%s", response.status(), response.reason(), bodyAsString); return new RuntimeException(message); } String message = String.format("Error %s. Reason: %s. Body content type: %s", response.status(), response.reason(), contentType); return new RuntimeException(message); } else { return new RuntimeException(String.format("%s %s", response.status(), response.reason())); } }