Skip to content

Commit

Permalink
Fix compiler errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
amatkivskiy committed Oct 4, 2016
1 parent 8695128 commit e88156b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 30 deletions.
Expand Up @@ -9,6 +9,7 @@
import com.amatkivskiy.gitter.sdk.model.error.GitterApiException;
import com.amatkivskiy.gitter.sdk.model.response.AccessTokenResponse;
import retrofit.Callback;
import retrofit.ErrorHandler;
import retrofit.RetrofitError;

import static com.amatkivskiy.gitter.sdk.Constants.GitterEndpoints.GITTER_AUTHENTICATION_ENDPOINT;
Expand Down Expand Up @@ -53,20 +54,23 @@ public static class Builder extends BaseApiBuilder<Builder, AsyncGitterAuthentic
@Override
public AsyncGitterAuthenticationClient build() {
restAdapterBuilder.setEndpoint(GITTER_AUTHENTICATION_ENDPOINT);
restAdapterBuilder.setErrorHandler(cause -> {
Throwable returnThrowable = cause;
if (cause.getKind() == RetrofitError.Kind.HTTP) {
if (cause.getResponse() != null) {
GitterApiErrorResponse errorResponse = (GitterApiErrorResponse) cause.getBodyAs(GitterApiErrorResponse.class);
restAdapterBuilder.setErrorHandler(new ErrorHandler() {
@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());
if (errorResponse != null) {
returnThrowable = new GitterApiException(errorResponse);
returnThrowable.setStackTrace(cause.getStackTrace());
}
}
}
}

return returnThrowable;
return returnThrowable;
}
});

AsyncGitterAuthenticateApi api = restAdapterBuilder.build().create(AsyncGitterAuthenticateApi.class);
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.amatkivskiy.gitter.sdk.model.response.AccessTokenResponse;
import com.amatkivskiy.gitter.sdk.rx.api.RxGitterAuthenticateApi;

import retrofit.ErrorHandler;
import retrofit.RetrofitError;
import rx.Observable;

Expand Down Expand Up @@ -49,20 +50,23 @@ public static class Builder extends BaseApiBuilder<Builder, RxGitterAuthenticati
@Override
public RxGitterAuthenticationClient build() {
restAdapterBuilder.setEndpoint(Constants.GitterEndpoints.GITTER_AUTHENTICATION_ENDPOINT);
restAdapterBuilder.setErrorHandler(cause -> {
Throwable returnThrowable = cause;
if (cause.getKind() == RetrofitError.Kind.HTTP) {
if (cause.getResponse() != null) {
GitterApiErrorResponse errorResponse = (GitterApiErrorResponse) cause.getBodyAs(GitterApiErrorResponse.class);
restAdapterBuilder.setErrorHandler(new ErrorHandler() {
@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());
if (errorResponse != null) {
returnThrowable = new GitterApiException(errorResponse);
returnThrowable.setStackTrace(cause.getStackTrace());
}
}
}
}

return returnThrowable;
return returnThrowable;
}
});

RxGitterAuthenticateApi api = restAdapterBuilder.build().create(RxGitterAuthenticateApi.class);
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.amatkivskiy.gitter.sdk.model.response.AccessTokenResponse;
import com.amatkivskiy.gitter.sdk.sync.api.SyncGitterAuthenticateApi;

import retrofit.ErrorHandler;
import retrofit.RetrofitError;

import static com.amatkivskiy.gitter.sdk.Constants.GitterEndpoints.GITTER_AUTHENTICATION_ENDPOINT;
Expand Down Expand Up @@ -50,20 +51,23 @@ public static class Builder extends BaseApiBuilder<Builder, SyncGitterAuthentica
@Override
public SyncGitterAuthenticationClient build() {
restAdapterBuilder.setEndpoint(GITTER_AUTHENTICATION_ENDPOINT);
restAdapterBuilder.setErrorHandler(cause -> {
Throwable returnThrowable = cause;
if (cause.getKind() == RetrofitError.Kind.HTTP) {
if (cause.getResponse() != null) {
GitterApiErrorResponse errorResponse = (GitterApiErrorResponse) cause.getBodyAs(GitterApiErrorResponse.class);
restAdapterBuilder.setErrorHandler(new ErrorHandler() {
@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());
if (errorResponse != null) {
returnThrowable = new GitterApiException(errorResponse);
returnThrowable.setStackTrace(cause.getStackTrace());
}
}
}
}

return returnThrowable;
return returnThrowable;
}
});

SyncGitterAuthenticateApi api = restAdapterBuilder.build().create(SyncGitterAuthenticateApi.class);
Expand Down

0 comments on commit e88156b

Please sign in to comment.