cancel
Showing results for 
Search instead for 
Did you mean: 

SnapLogic Errors: Return custom payload and fail pipeline

omair
Contributor

Is it possible within SnapLogic to configure a pipeline to fail via a Snap but also to return a custom output back to the user (configured via a Mapper snap, e.g.)

I have reviewed the video here: Framework: Error Handling & Retry Patterns and it appears that a SnapLogic pipeline can either:

  • fail with limited control on the error message (e.g. using the Exit snap which allows for a text message) OR
  • specify a detailed error message (e.g. via an error pipeline or directly)… in this case the pipeline is marked completed.
6 REPLIES 6

Could you include some more information regarding your implementation and what you’re trying to do? If I understand your question you are trying to check if there were failed insertions. If so, then the task should respond with an error message and a non-200 status code. If that’s correct then you might look at this kind of pipeline.

Screen Shot 2022-11-02 at 4.28.40 PM

You can use the JSON Generator to set the failed count, which will determine if there is an error. Here are some additional notes for the 4 key snaps required to get this done.

  1. This Router will check for failures and if surpasses the error threshold, routes the document to the bottom output view.
  2. The Set Error mapper snap will set an error message and status code that the task should return in the HTTP response.
  3. The exit snap will surpass the threshold and is used to put the pipeline in a failed state.
  4. The JSON formatter can be used to set the status code on the HTTP response. This is done by setting a special field called status in the binary document header.

When executed as a triggered task, then you should see this kind of response. I removed some headers from the response to make it easier to read.

< HTTP/1.1 500 INTERNAL SERVER ERROR
< Date: Wed, 02 Nov 2022 20:33:46 GMT
< Content-Type: application/json; charset=utf-8
< X-SL-StatusCode: 500
< X-Snapi-pipeline-ruuid: XXXX08ba
...
<
[{"status":500,"error":"oh no!"}]

In the dashboard it’ll show up like this.

image

Here is an attached pipeline if you’d like to try it out.

exit-example_2022_11_02.slp (9.9 KB)

bojanvelevski
Valued Contributor

Are you referring to a custom binary header, so you could manipulate the response? If that’s the case, you can use Mapper to map the status and the message, than add a JSON Formatter snap, and add the incoming status and message in a binary header properties.

Understanding Synchronous and Asynchronous Execution of Triggered Tasks

Hope this helps,

Regards,

Bojan Velevski