use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerConfigManagementService method handleCORSException.
private APIError handleCORSException(CORSManagementServiceException e, Constants.ErrorMessage errorEnum, String data) {
ErrorResponse errorResponse;
Response.Status status;
if (e instanceof CORSManagementServiceClientException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e.getMessage());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorCode = errorCode.contains(org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER) ? errorCode : Constants.CONFIG_ERROR_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.BAD_REQUEST;
} else if (e instanceof CORSManagementServiceServerException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.description());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorCode = errorCode.contains(org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER) ? errorCode : Constants.CONFIG_ERROR_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.INTERNAL_SERVER_ERROR;
} else {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.description());
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerRemoteFetchConfigManagementService method handleRemoteFetchConfigurationException.
/**
* This method is used to handle remote fetch core exception and create API error wit suitable response code and
* status by checking its instance type.
*
* @param e RemoteFetchCoreException.
* @param errorEnum RemoteFetchConfigurationConstants.ErrorMessage
* @param data data
* @return APIError
*/
private APIError handleRemoteFetchConfigurationException(RemoteFetchCoreException e, RemoteFetchConfigurationConstants.ErrorMessage errorEnum, String data) {
ErrorResponse errorResponse;
Response.Status status;
if (e instanceof RemoteFetchClientException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e.getMessage());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorCode = errorCode.contains(RemoteFetchConfigurationConstants.ERROR_CODE_DELIMITER) ? errorCode : RemoteFetchConfigurationConstants.REMOTE_FETCH_CONFIGURATION_MANAGEMENT_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.BAD_REQUEST;
} else if (e instanceof RemoteFetchServerException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorCode = errorCode.contains(RemoteFetchConfigurationConstants.ERROR_CODE_DELIMITER) ? errorCode : RemoteFetchConfigurationConstants.REMOTE_FETCH_CONFIGURATION_MANAGEMENT_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.INTERNAL_SERVER_ERROR;
} else {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerApplicationMetadataService method handleException.
/**
* If the passed exception has an error message, set it to the description of the API error response.
*
* @param e Exception caught.
* @return APIError with exception error message if present.
*/
private APIError handleException(Exception e) {
ErrorMessage errorEnum = ERROR_RETRIEVING_SAML_METADATA;
String description = errorEnum.getDescription();
if (StringUtils.isNotBlank(e.getMessage())) {
description = e.getMessage();
}
return Utils.buildServerError(errorEnum.getCode(), errorEnum.getMessage(), description, e);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class Utils method buildNotFoundError.
public static APIError buildNotFoundError(String errorCode, String message, String description) {
ErrorResponse errorResponse = new ErrorResponse.Builder().withCode(errorCode).withMessage(message).withDescription(description).build(log, description);
Response.Status status = Response.Status.NOT_FOUND;
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class Utils method buildClientError.
public static APIError buildClientError(String errorCode, String message, String description) {
ErrorResponse errorResponse = new ErrorResponse.Builder().withCode(errorCode).withMessage(message).withDescription(description).build(log, description);
Response.Status status = Response.Status.BAD_REQUEST;
return new APIError(status, errorResponse);
}
Aggregations