Forum Discussion

sp41832's avatar
sp41832
New Contributor II
8 years ago

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.

4 Replies

  • 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

    • sp41832's avatar
      sp41832
      New Contributor II

      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

      • Supratim's avatar
        Supratim
        Contributor III

        @sp41832

        Use below syntax on mapper-

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