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

del
Contributor III

@omair, This may not be your exact use case, but here is a high-level view of how I do something similar to this:

  • On an error view, add the custom message mapper and notification snap just prior to the exit snap.
  • Then join the non-error output view to the exit output view with a union+sort to ensure processing doesn’t continue before the exit has time to process (you can eliminate this piece if you don’t care if valid records are processed before an error exit is triggered).
  • If the exit isn’t triggered, then the pipeline will continue.

image

(Edit) - The above works with email notifications - which is what I first read into your question - possibly incorrectly. However, if you’re looking for API type output to the user, this example will not work.

omair
Contributor

Thanks @del … but, yeah…

I was looking for API-type output to the user…

hey omair,

Have you tried the Exit snap? It allows you to set an error message that can be returned to the user.

image

If you call that via a triggered task, then you’ll get this kind of response.

[
      {
      "failure" : "Pipeline execution failed while waiting for output",
      "reason" : "Snap errors: {ruuid=52e99318640a9a03d8681d0d_9b3dd03a-dde2-43e8-a0ba-fd58239c2a5d, reason=Number of input documents received is more than 0, label=Exit, resolution=Try passing less than or equal to 0 input documents, failure=Beep Boop! Failure!}",
      "resolution" : "Fix the reported errors"
    }
]

You’d still have to extract it from the reason String, so not the most user friendly way.

You could also do something like this:

image

Where the mapper returns the output before the exit snap is invoked using a sleep in a Script snap. This will return a response like

[
    {
        "error": "Beep Boop! Failure!"
    }
]

Which is easier to deal with.

This isn’t the most elegant approach since there is a race condition between when the mapper’s output is written out and when the exit snap processes the document from its input stream.

Hi Tlikarish,
I would like to make the pipe line status as failed instead of completed.
My rest API sends the status as ok where few record inserted and few failed. I am counting if failed records >0 , then I am logging those record in log then exiting with exit snap. But the pipeline status is not failing. It shows completed. I want the pipe line status should show as failed.
Regards
Gyanendra