exceptionfactory commented on a change in pull request #5606:
URL: https://github.com/apache/nifi/pull/5606#discussion_r772846494



##########
File path: 
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java
##########
@@ -315,6 +318,23 @@ protected final AccessControlList createACL(final 
ProcessContext context, final
         return acl;
     }
 
+    protected FlowFile extractExceptionDetails(final Exception e, final 
ProcessSession session, FlowFile flowFile) {
+        flowFile = session.putAttribute(flowFile, "s3.exception", 
e.getClass().getName());
+        if (e instanceof AmazonS3Exception) {
+            flowFile = putAttribute(session, flowFile, "s3.additionalDetails", 
((AmazonS3Exception) e).getAdditionalDetails());
+        }
+        if (e instanceof AmazonServiceException) {
+            flowFile = putAttribute(session, flowFile, "s3.statusCode", 
((AmazonServiceException) e).getStatusCode());
+            flowFile = putAttribute(session, flowFile, "s3.errorCode", 
((AmazonServiceException) e).getErrorCode());
+            flowFile = putAttribute(session, flowFile, "s3.errorMessage", 
((AmazonServiceException) e).getErrorMessage());

Review comment:
       Just a minor adjustment, it looks like the exception could be cast once 
as an `AmazonServiceException` and then the various methods could be called.
   ```suggestion
               final AmazonServiceException ase = (AmazonServiceException) e;
               flowFile = putAttribute(session, flowFile, "s3.statusCode", 
ase.getStatusCode());
               flowFile = putAttribute(session, flowFile, "s3.errorCode", 
ase.getErrorCode());
               flowFile = putAttribute(session, flowFile, "s3.errorMessage", 
ase.getErrorMessage());
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to