|
15 | 15 | package software.amazon.cloudformation; |
16 | 16 |
|
17 | 17 | import com.amazonaws.AmazonServiceException; |
| 18 | +import com.amazonaws.retry.RetryUtils; |
18 | 19 | import com.fasterxml.jackson.core.type.TypeReference; |
19 | 20 | import com.fasterxml.jackson.databind.exc.MismatchedInputException; |
20 | 21 | import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; |
@@ -373,9 +374,16 @@ private void logUnhandledError(final String errorDescription, |
373 | 374 | logUnhandledError(e.getMessage(), request, e); |
374 | 375 | return ProgressEvent.defaultFailureHandler(e, e.getErrorCode()); |
375 | 376 | } catch (final AmazonServiceException | AwsServiceException e) { |
376 | | - publishExceptionMetric(request.getAction(), e, HandlerErrorCode.GeneralServiceException); |
377 | | - logUnhandledError("A downstream service error occurred", request, e); |
378 | | - return ProgressEvent.defaultFailureHandler(e, HandlerErrorCode.GeneralServiceException); |
| 377 | + if ((e instanceof AwsServiceException && ((AwsServiceException) e).isThrottlingException()) || |
| 378 | + (e instanceof AmazonServiceException && RetryUtils.isThrottlingException((AmazonServiceException) e))) { |
| 379 | + this.log(String.format("%s [%s] call throttled by downstream service", request.getResourceType(), request.getAction())); |
| 380 | + publishExceptionMetric(request.getAction(), e, HandlerErrorCode.Throttling); |
| 381 | + return ProgressEvent.defaultFailureHandler(e, HandlerErrorCode.Throttling); |
| 382 | + } else { |
| 383 | + publishExceptionMetric(request.getAction(), e, HandlerErrorCode.GeneralServiceException); |
| 384 | + logUnhandledError("A downstream service error occurred", request, e); |
| 385 | + return ProgressEvent.defaultFailureHandler(e, HandlerErrorCode.GeneralServiceException); |
| 386 | + } |
379 | 387 | } catch (final Throwable e) { |
380 | 388 | publishExceptionMetric(request.getAction(), e, HandlerErrorCode.InternalFailure); |
381 | 389 | logUnhandledError("An unknown error occurred ", request, e); |
|
0 commit comments