in aws-lightsail-database/src/main/java/software/amazon/lightsail/database/BaseHandlerStd.java [49:116]
protected abstract ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy, final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext, final ProxyClient<LightsailClient> proxyClient, final Logger logger);
/**
* This method handles the exceptions which are caught in the handlers, returns in progress if those error codes are
* ignored, or retires with a delay if error codes are retryable, or emits an appropriate error code
*
* @param e
* exception which was caught
* @param resourceModel
* desired resource model for the request
* @param callbackContext
* callback context for current invocation
* @param ignoreErrorCodes
* error codes which should be ignored, i.e. code which should return in-progress
* @param logger
* logger to log statements
*
* @return ProgressEvent<ResourceModel, CallbackContext>
*/
public static ProgressEvent<ResourceModel, CallbackContext> handleError(final Exception e,
final ResourceModel resourceModel, final CallbackContext callbackContext,
final List<String> ignoreErrorCodes, final Logger logger, final String errorLocation) {
logger.log(String.format("Error during operation: %s, Error message: %s", errorLocation, e.getMessage()));
logger.log(Arrays.toString(e.getStackTrace()));
if (e instanceof AwsServiceException) {
final String errorCode = ((AwsServiceException) e).awsErrorDetails().errorCode();
if (ignoreErrorCodes.contains(errorCode)) {
logger.log("This error is expected at this stage. Continuing execution.");
return ProgressEvent.progress(resourceModel, callbackContext);
}
logger.log(String.format("%s", ((AwsServiceException) e).awsErrorDetails()));
switch (errorCode) {
case NotFoundException:
return ProgressEvent.defaultFailureHandler(new CfnNotFoundException(e),
HandlerErrorCode.NotFound);
case InvalidInputException:
case InvalidParameterCombination:
case InvalidQueryParameter:
case InvalidAction:
case ValidationError:
case MissingParameter:
case OperationFailureException:
return ProgressEvent.defaultFailureHandler(new CfnInvalidRequestException(e),
HandlerErrorCode.InvalidRequest);
case ThrottlingException:
return ProgressEvent.defaultFailureHandler(new CfnThrottlingException(e), HandlerErrorCode.Throttling);
case NotAuthorized:
case OptInRequired:
case AccessDeniedException:
case UnauthenticatedException:
return ProgressEvent.defaultFailureHandler(new CfnAccessDeniedException(e),
HandlerErrorCode.AccessDenied);
case InternalFailure:
case ServiceUnavailable:
default:
return ProgressEvent.defaultFailureHandler(new CfnGeneralServiceException(e),
HandlerErrorCode.GeneralServiceException);
}
}
return ProgressEvent.defaultFailureHandler(new CfnGeneralServiceException(e),
HandlerErrorCode.GeneralServiceException);
}