stepMilli, 0, true, program); } catch (RetrofitError e) { ErrorResponse errorResponse = (ErrorResponse) e.getBodyAs(ErrorResponse.class); throw new SignalFxRequestError(errorResponse, program, startEpochMilli, endEpochMilli, stepMilli, metricsAccountName);
/** * HTTP response body converted to the type declared by either the interface method return type * or the generic type of the supplied {@link Callback} parameter. {@code null} if there is no * response. * * @throws RuntimeException if unable to convert the body to the {@link #getSuccessType() success * type}. */ public Object getBody() { return getBodyAs(successType); }
@Override public Throwable handleError(RetrofitError cause) { JsonObject jsonObject = (JsonObject) cause.getBodyAs(JsonObject.class); String message = jsonObject.get("error").getAsString(); return new RuntimeException(message); } }).build().create(Endpoints.class);
@Override public void failure(RetrofitError error) { try { if(error.getResponse().getStatus() == 401){ //your service for refreshing the token } else{ JsonElement json = (JsonElement) error.getBodyAs(JsonElement.class); String err = json.getAsJsonObject().get("err").getAsString(); } } catch (Exception e) { // handle the exception } }
if (response == null) { log.warn("Unexpected error disabling orca", e); } else if (response.getStatus() == 400 && ((Map) e.getBodyAs(Map.class)) .containsKey("discovery")) { log.info("Orca instance is managed by eureka");
if (response == null) { log.warn("Unexpected error disabling orca", e); } else if (response.getStatus() == 400 && ((Map) e.getBodyAs(Map.class)) .containsKey("discovery")) { log.info("Orca instance is managed by eureka");
@Override public Throwable handleError(RetrofitError cause) { Throwable returnThrowable = cause; if (cause.getKind() == RetrofitError.Kind.HTTP) { if (cause.getResponse() != null) { GitterApiErrorResponse errorResponse = (GitterApiErrorResponse) cause.getBodyAs(GitterApiErrorResponse.class); if (errorResponse != null) { returnThrowable = new GitterApiException(errorResponse); returnThrowable.setStackTrace(cause.getStackTrace()); } } } return returnThrowable; } });
@Override public Throwable handleError(RetrofitError cause) { Throwable returnThrowable = cause; if (cause.getKind() == RetrofitError.Kind.HTTP) { if (cause.getResponse() != null) { GitterApiErrorResponse errorResponse = (GitterApiErrorResponse) cause.getBodyAs(GitterApiErrorResponse.class); if (errorResponse != null) { returnThrowable = new GitterApiException(errorResponse); returnThrowable.setStackTrace(cause.getStackTrace()); } } } return returnThrowable; } });
@Override public Throwable handleError(RetrofitError cause) { Throwable returnThrowable = cause; if (cause.getKind() == RetrofitError.Kind.HTTP) { if (cause.getResponse() != null) { GitterApiErrorResponse errorResponse = (GitterApiErrorResponse) cause.getBodyAs(GitterApiErrorResponse.class); if (errorResponse != null) { returnThrowable = new GitterApiException(errorResponse); returnThrowable.setStackTrace(cause.getStackTrace()); } } } return returnThrowable; } });
private HalException handleVaultError(RetrofitError e, String operation) { if (e.getResponse() != null && e.getResponse().getStatus() == 400) { VaultError ve = (VaultError) e.getBodyAs(VaultError.class); return new HalException(Problem.Severity.FATAL, "Vault is in an invalid state: " + ve, e); } else { return new HalException(Problem.Severity.FATAL, "Error reaching vault during operation \"" + operation + "\"", e); } }
private HalException handleVaultError(RetrofitError e, String operation) { if (e.getResponse() != null && e.getResponse().getStatus() == 400) { VaultError ve = (VaultError) e.getBodyAs(VaultError.class); return new HalException(Problem.Severity.FATAL, "Vault is in an invalid state: " + ve, e); } else { return new HalException(Problem.Severity.FATAL, "Error reaching vault during operation \"" + operation + "\"", e); } }
try { HatchetAuthResponse authResponse = (HatchetAuthResponse) e.getBodyAs(HatchetAuthResponse.class); if (authResponse != null && authResponse.error != null && authResponse.error.equals(RESPONSE_ERROR_INVALID_REQUEST)) {
try { HatchetAuthResponse authResponse = (HatchetAuthResponse) e.getBodyAs(HatchetAuthResponse.class); if (authResponse != null && authResponse.error != null && authResponse.error.equals(RESPONSE_ERROR_INVALID_REQUEST)) {
boolean enabled = roscoSettings.getEnabled() != null && roscoSettings.getEnabled(); if (enabled) { String message = ((Map<String, String>) e.getBodyAs(Map.class)).get("message"); throw new HalException(Problem.Severity.FATAL, "Rosco is enabled, and no connection to rosco could be established: " + e + ": " + message, e);
stepMilli, 0, true, program); } catch (RetrofitError e) { ErrorResponse errorResponse = (ErrorResponse) e.getBodyAs(ErrorResponse.class); throw new SignalFxRequestError(errorResponse, program, startEpochMilli, endEpochMilli, stepMilli, metricsAccountName);
boolean enabled = roscoSettings.getEnabled() != null && roscoSettings.getEnabled(); if (enabled) { Map<String, String> body = (Map<String, String>) e.getBodyAs(Map.class); String message; if (body != null) {
ErrorResponse errorResponse = (ErrorResponse) cause.getBodyAs(ErrorResponse.class); errorDescription = errorResponse.error.data.message; } catch (Exception ex) {
HodError hodError = (HodError) retrofitError.getBodyAs(HodError.class);
try { HatchetAuthResponse authResponse = (HatchetAuthResponse) e.getBodyAs(HatchetAuthResponse.class); if (authResponse != null && (authResponse.error != null || !VariousUtils.containsIgnoreCase(tokenType, authResponse.token_type))) {
distributedService); } catch (RetrofitError e) { String message = ((Map<String, String>) e.getBodyAs(Map.class)).get("message"); throw new HalException(Problem.Severity.FATAL, "Unable to deploy service with Orca " + e + ": " + message, e);