Error Handling - storing errors in multiple external calls to be able to return in the webhook response | Community
Skip to main content
VictorToledo_
Level 3
November 1, 2024
Solved

Error Handling - storing errors in multiple external calls to be able to return in the webhook response

  • November 1, 2024
  • 1 reply
  • 1404 views

Hi all,

I have a flow where I'm iterating over a list of file names that I need to get from an S3. The flow is working fine, but now I want to add better error handling and be able to return the list of files that were successfully fetched and a list of those that had errors.

I have the Iterate module, then the S3 and in the error handling I'm accumulating in a variable the names of files that fail, but in the webhook response I can't use this value.
I mean, I don't want to add a webhook response after the errors, because the flow continues, I want to be able to use the general webook response and make reference to this variable to return it in the flow response.

 

 

i want to have something

 

response status 200

{

"errors" : ["file1", "file5"],

"success": ["file2","file3","file4]

}

 

 

thanks in advance!

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sven-iX

Hello @sven-ix 

Yes, I have tried, I mean using Resume, but in this case as I'm using an s3 module the Resume needs ‘fileName’ and ‘data’ to resume the stream, so it is not clear to me why use it.

I'm testing the flow with 4 files that fail and 3 that work. In this case the main flow is executed 3 times and the error one 4 times, that's why I think the problem occurs, when the reading of the variable (the get err of the main flow) is executed only 3 times, the last error value is lost.


Well - the code i sent works the way you describe - did you compare to yours? 

Ignore ends the processing. Resume continues the processing. 

You can put whatever in the fields or leave them blank: once you resume we catch the error and move on. The resume is for when you want to set values that the next module would use after an error condition.

1 reply

Sven-iX
Community Advisor
Community Advisor
November 1, 2024

Hi @victortoledo_ 

 

try this: (JSON attached)

  • branch into processing files & capturing results
  • processing
    • the S3 error handler sets a "err" variable and ends in an ignore so the processing continues
    • after getting the err msg we check
      • is error: create a JSON string {"file":"#####","error":"####"}
      • no error: just collect the file name {"file":"#####"}, use comma as separator
      • set the variable of the aggregated strings
  • capture results
    • simple getVar > stuff into webhookResponse.

 

 

 

VictorToledo_
Level 3
November 5, 2024

Hi @sven-ix 

thank you very much for your help.

I tried something similar but i still having issues

my input json is something similar to

{"array1":[

                {"pro1":"val1","prop2":"val2","files-to-import":["image1.jpg","booking1_error.jpg"]},

                {"pro4":"val4","prop5":"val5","files-to-import":["booking2_error.jpg","image6.jpg",booking21_error.jpg]}

                {"pro23":"val23","prop25":"val25","files-to-import":[booking3_error.jpg,"image26.jpg","]},

               ]

}

So the ‘bookingX_error.jpg’ should cause the error and be returned in the response as ‘errors’. But as you can see the get error variable in the main stream is not getting all the error values from the set var in the error handling stream.

 

This is the get variable in the main flow (3 operations, it is wrong)

 

 

 

This is the Set variable in the error handling flow (4 errors, it is correct)

 

any input is welcome!

thanks in advance

Sven-iX
Community Advisor
Sven-iXCommunity AdvisorAccepted solution
Community Advisor
November 6, 2024

Hello @sven-ix 

Yes, I have tried, I mean using Resume, but in this case as I'm using an s3 module the Resume needs ‘fileName’ and ‘data’ to resume the stream, so it is not clear to me why use it.

I'm testing the flow with 4 files that fail and 3 that work. In this case the main flow is executed 3 times and the error one 4 times, that's why I think the problem occurs, when the reading of the variable (the get err of the main flow) is executed only 3 times, the last error value is lost.


Well - the code i sent works the way you describe - did you compare to yours? 

Ignore ends the processing. Resume continues the processing. 

You can put whatever in the fields or leave them blank: once you resume we catch the error and move on. The resume is for when you want to set values that the next module would use after an error condition.