Extracting from Json error

Hi,

i have a json error as below

“error”: “Pipeline did not complete successfully”,
“stacktrace”: “com.snaplogic.snap.api.SnapDataException: Pipeline did not complete successfully\n\tat com.snaplogic.snaps.flow.PipeExec$PipeCompletionHandler.run(PipeExec.java:1245)\n\tat com.snaplogic.snaps.flow.PipeExec$2.run(PipeExec.java:728)\n\tat java.lang.Thread.run(Thread.java:748)\n”,
“reason”: “Snap errors: {ruuid=ba88d53f-a76b-4557-9da4-469c054f5ba0, reason=Table ‘Netsuite.PAYROLL_ITEMS’ doesn’t exist, error code: 1146, SQL state: 42S02, failure=SQL operation failed, label=MySQL - Execute, resolution=Please check for valid Snap properties and input data.}”,
“resolution”: “Fix the child pipeline errors and try again”,
“status_code”: “error”,
“run_id”: “372fce27-d73b-41e3-9f61-d26b1af4f1c5”,
“child_errors”: [
{
“ruuid”: “ba88d53f-a76b-4557-9da4-469c054f5ba0”,
“reason”: “Table ‘Netsuite.PAYROLL_ITEMS’ doesn’t exist, error code: 1146, SQL state: 42S02”,

Can i extract the highlighted text and put it in a file in my data base.
strong text.

The design is somehting like this, I have a regular pipeline which calls an error pipeline on receiving any error, the error i receive is in Json and i need to have only the error highlighted above, is it Possinle and how?

Thanks in Advance.

It is certainly possible. There are other ways it could be done, though I have used the regular scripting object to do things like this. You CAN, obviously just pull child_errors.reason, and call it a day.

Steve

Hi Stephen,

Used Json splitter, and given the Json Path* as $[][][0:9]
and the result was
“ruuid”: “b40505c0-59a0-480b-b4cd-b35633007107”,
“reason”: “Table ‘Netsuite.PAYROLL_ITEMS’ doesn’t exist, error code: 1146, SQL state: 42S02”,
“failure”: “SQL operation failed”,
“label”: “MySQL - Execute”,
“resolution”: “Please check for valid Snap properties and input data.”
the link where i verified is “http://jsonpath.com”, however the snaplogic does not allow this.

Let me know , how can i extract the error

@sp41832

Use below syntax on mapper-

$reason.substring($reason.indexOf(’{’),$reason.length).split(’,’)[1].toString()

In the splitter, you can put the base object, like $ child_errors, though as long as you end up with a proper jason object, you can use it.

In a mapper, in this particular case, $reason will be set to: Table ‘Netsuite.PAYROLL_ITEMS’ doesn’t exist, error code: 1146, SQL state: 42S02

You are over thinking this as, internally, stuff like this is treated as jason and given special treatment as such. Of course formatting as CSV allows you to treat it that way, etc… AND, if you have this down to one level, you can even have it formatted to CSV.

So a lot of what you are trying to work through is already done.

This is also why supratim’s method will work. If you notice, it starts with the string “$reason”. The other items, like .substring() are methods you can use on that string to do things like extract a portion of it.