public static BaseHandlerException translateForAPIException()

in aws-panorama-applicationinstance/src/main/java/software/amazon/panorama/applicationinstance/PanoramaExceptionTranslator.java [21:43]


    public static BaseHandlerException translateForAPIException(final PanoramaException e,
                                                                final String operation,
                                                                final String resourceTypeName,
                                                                final String resourceIdentifier,
                                                                final String requestBody
    ) {
        if (e instanceof ValidationException) {
            return new CfnInvalidRequestException(requestBody, e);
        } else if (e instanceof ConflictException) {
            return new CfnResourceConflictException(resourceTypeName, resourceIdentifier,
                    String.format("%s already existed", resourceIdentifier), e);
        } else if (e instanceof AccessDeniedException) {
            return new CfnAccessDeniedException(e);
        } else if (e instanceof InternalServerException) {
            return new CfnInternalFailureException(e);
        } else if (e instanceof ResourceNotFoundException) {
            return new CfnNotFoundException(resourceTypeName, resourceIdentifier, e);
        } else if (e instanceof ServiceQuotaExceededException) {
            return new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME, "Exceeded service limit", e);
        }

        return new CfnGeneralServiceException(operation, e);
    }