use of org.apache.pulsar.client.admin.PulsarAdminException.NotAllowedException in project pulsar by yahoo.
the class BaseResource method getApiException.
public PulsarAdminException getApiException(Throwable e) {
if (e instanceof PulsarAdminException) {
return (PulsarAdminException) e;
} else if (e instanceof ServiceUnavailableException) {
if (e.getCause() instanceof java.net.ConnectException) {
return new ConnectException(e.getCause());
} else {
ServerErrorException see = (ServerErrorException) e;
int statusCode = see.getResponse().getStatus();
String httpError = getReasonFromServer(see);
return new PulsarAdminException(e, httpError, statusCode);
}
} else if (e instanceof WebApplicationException) {
// Handle 5xx exceptions
if (e instanceof ServerErrorException) {
ServerErrorException see = (ServerErrorException) e;
int statusCode = see.getResponse().getStatus();
String httpError = getReasonFromServer(see);
return new ServerSideErrorException(see, httpError, httpError, statusCode);
} else if (e instanceof ClientErrorException) {
// Handle 4xx exceptions
ClientErrorException cee = (ClientErrorException) e;
int statusCode = cee.getResponse().getStatus();
String httpError = getReasonFromServer(cee);
switch(statusCode) {
case 401:
case 403:
return new NotAuthorizedException(cee, httpError, statusCode);
case 404:
return new NotFoundException(cee, httpError, statusCode);
case 405:
return new NotAllowedException(cee, httpError, statusCode);
case 409:
return new ConflictException(cee, httpError, statusCode);
case 412:
return new PreconditionFailedException(cee, httpError, statusCode);
default:
return new PulsarAdminException(httpError, cee, httpError, statusCode);
}
} else {
WebApplicationException wae = (WebApplicationException) e;
int statusCode = wae.getResponse().getStatus();
String httpError = getReasonFromServer(wae);
return new PulsarAdminException(httpError, wae, httpError, statusCode);
}
} else {
return new PulsarAdminException(e);
}
}
use of org.apache.pulsar.client.admin.PulsarAdminException.NotAllowedException in project incubator-pulsar by apache.
the class BaseResource method getApiException.
public PulsarAdminException getApiException(Throwable e) {
if (e instanceof PulsarAdminException) {
return (PulsarAdminException) e;
} else if (e instanceof ServiceUnavailableException) {
if (e.getCause() instanceof java.net.ConnectException) {
return new ConnectException(e.getCause());
} else {
ServerErrorException see = (ServerErrorException) e;
int statusCode = see.getResponse().getStatus();
String httpError = getReasonFromServer(see);
return new PulsarAdminException(e, httpError, statusCode);
}
} else if (e instanceof WebApplicationException) {
// Handle 5xx exceptions
if (e instanceof ServerErrorException) {
ServerErrorException see = (ServerErrorException) e;
int statusCode = see.getResponse().getStatus();
String httpError = getReasonFromServer(see);
return new ServerSideErrorException(see, httpError, httpError, statusCode);
} else if (e instanceof ClientErrorException) {
// Handle 4xx exceptions
ClientErrorException cee = (ClientErrorException) e;
int statusCode = cee.getResponse().getStatus();
String httpError = getReasonFromServer(cee);
switch(statusCode) {
case 401:
case 403:
return new NotAuthorizedException(cee, httpError, statusCode);
case 404:
return new NotFoundException(cee, httpError, statusCode);
case 405:
return new NotAllowedException(cee, httpError, statusCode);
case 409:
return new ConflictException(cee, httpError, statusCode);
case 412:
return new PreconditionFailedException(cee, httpError, statusCode);
default:
return new PulsarAdminException(httpError, cee, httpError, statusCode);
}
} else {
WebApplicationException wae = (WebApplicationException) e;
int statusCode = wae.getResponse().getStatus();
String httpError = getReasonFromServer(wae);
return new PulsarAdminException(httpError, wae, httpError, statusCode);
}
} else {
return new PulsarAdminException(e);
}
}
use of org.apache.pulsar.client.admin.PulsarAdminException.NotAllowedException in project pulsar by apache.
the class BaseResource method getApiException.
public PulsarAdminException getApiException(Throwable e) {
if (e instanceof PulsarAdminException) {
return (PulsarAdminException) e;
} else if (e instanceof ServiceUnavailableException) {
if (e.getCause() instanceof java.net.ConnectException) {
return new ConnectException(e.getCause());
} else {
ServerErrorException see = (ServerErrorException) e;
int statusCode = see.getResponse().getStatus();
String httpError = getReasonFromServer(see);
return new PulsarAdminException(e, httpError, statusCode);
}
} else if (e instanceof WebApplicationException) {
// Handle 5xx exceptions
if (e instanceof ServerErrorException) {
ServerErrorException see = (ServerErrorException) e;
int statusCode = see.getResponse().getStatus();
String httpError = getReasonFromServer(see);
return new ServerSideErrorException(see, e.getMessage(), httpError, statusCode);
} else if (e instanceof ClientErrorException) {
// Handle 4xx exceptions
ClientErrorException cee = (ClientErrorException) e;
int statusCode = cee.getResponse().getStatus();
String httpError = getReasonFromServer(cee);
switch(statusCode) {
case 401:
case 403:
return new NotAuthorizedException(cee, httpError, statusCode);
case 404:
return new NotFoundException(cee, httpError, statusCode);
case 405:
return new NotAllowedException(cee, httpError, statusCode);
case 409:
return new ConflictException(cee, httpError, statusCode);
case 412:
return new PreconditionFailedException(cee, httpError, statusCode);
default:
return new PulsarAdminException(httpError, cee, httpError, statusCode);
}
} else {
WebApplicationException wae = (WebApplicationException) e;
int statusCode = wae.getResponse().getStatus();
String httpError = getReasonFromServer(wae);
return new PulsarAdminException(httpError, wae, httpError, statusCode);
}
} else {
return new PulsarAdminException(e);
}
}
Aggregations