/** * Return the request URL. * * @return the request URL */ public String getUrl() { return retrofitError.getUrl(); }
public class RetrofitCallback<S> implements Callback<S> { private static final String TAG = RetrofitCallback.class.getSimpleName(); @Override public void success(S s, Response response) { } @Override public void failure(RetrofitError error) { Log.e(TAG, "Failed to make http request for: " + error.getUrl()); Response errorResponse = error.getResponse(); if (errorResponse != null) { Log.e(TAG, errorResponse.getReason()); if (errorResponse.getStatus() == 500) { Log.e(TAG, "Handle Server Errors Here"); } } } }
public class RetrofitCallback<S> implements Callback<S> { private static final String TAG = RetrofitCallback.class.getSimpleName(); @Override public void success(S s, Response response) { } @Override public void failure(RetrofitError error) { Log.e(TAG, "Failed to make http request for: " + error.getUrl()); Response errorResponse = error.getResponse(); if (errorResponse != null) { Log.e(TAG, errorResponse.getReason()); if (errorResponse.getStatus() == 500) { Log.e(TAG, "Handle Server Errors Here"); } } } }
@SuppressWarnings("unchecked") @Override public final void run() { try { final ResponseWrapper wrapper = obtainResponse(); callbackExecutor.execute(new Runnable() { @Override public void run() { callback.success((T) wrapper.responseBody, wrapper.response); } }); } catch (RetrofitError e) { Throwable cause = errorHandler.handleError(e); final RetrofitError handled = cause == e ? e : unexpectedError(e.getUrl(), cause); callbackExecutor.execute(new Runnable() { @Override public void run() { callback.failure(handled); } }); } }
@Override public Throwable handleError(RetrofitError retrofitError) { L.e(retrofitError + "请求出现错误:%s" + retrofitError.getUrl()); RetrofitError.Kind kind = retrofitError.getKind(); String message; if (RetrofitError.Kind.NETWORK.equals(kind)) { message = ctx.getString(R.string.network_error); } else if (RetrofitError.Kind.HTTP.equals(kind)) { message = ctx.getString(R.string.http_error); } else if (RetrofitError.Kind.CONVERSION.equals(kind)) { message = ctx.getString(R.string.conversion_error); } else { message = ctx.getString(R.string.unexpected_error); } return new Exception(message); } };
private UpstreamBadRequest(RetrofitError cause) { super(cause.getMessage(), cause); status = cause.getResponse().getStatus(); url = cause.getUrl(); }
public AmbariApiException(RetrofitError retrofitError) { super(MessageFormat.format(ERROR_MESSAGE, retrofitError.getResponse().getStatus(), retrofitError.getUrl(), new String(((TypedByteArray) retrofitError.getResponse().getBody()).getBytes()))); } }
httpEx.responseBody, methodInfo.responseObjectType); Throwable cause = restAdapter.errorHandler.handleError(error); final RetrofitError e = cause == error ? error : unexpectedError(error.getUrl(), cause); callback.failure(e);
final RetrofitError e = cause == error ? error : unexpectedError(error.getUrl(), cause); restAdapter.callbackExecutor.execute(new Runnable() { @Override public void run() {
discard = true; } catch (RetrofitError e) { Log.e(TAG, "send: Request to " + e.getUrl() + " failed: " + e.getClass() + ": " + e.getLocalizedMessage()); if (e.getResponse() != null && e.getResponse().getStatus() == 500) { Log.e(TAG, "send: discarding oplog that has failed to be sent to " + e .getUrl()); discard = true;
Log.e(TAG, "getParseConvert: Request to " + e.getUrl() + " failed: " + e.getClass() + ": " + e.getLocalizedMessage());