@Override
 public boolean apply(Exception input) {
   @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
   AWSResponseException exception =
       Exceptions.getFirstThrowableOfType(input, AWSResponseException.class);
   if (exception != null) {
     String code = exception.getError().getCode();
     return AWS_ERRORS_TO_RETRY.contains(code);
   }
   return false;
 }
 private EntitySpec<? extends Application> createEntitySpecForApplication(String potentialYaml) {
   try {
     return EntityManagementUtils.createEntitySpecForApplication(mgmt(), potentialYaml);
   } catch (Exception e) {
     // An IllegalArgumentException for creating the entity spec gets wrapped in a ISE, and
     // possibly a Compound.
     // But we want to return a 400 rather than 500, so ensure we throw IAE.
     IllegalArgumentException iae =
         (IllegalArgumentException)
             Exceptions.getFirstThrowableOfType(e, IllegalArgumentException.class);
     if (iae != null) {
       throw new IllegalArgumentException("Cannot create spec for app: " + iae.getMessage(), e);
     } else {
       throw Exceptions.propagate(e);
     }
   }
 }