โ07-09-2018 09:59 PM
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.
โ07-10-2018 07:57 AM
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
โ07-10-2018 04:10 PM
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
โ07-10-2018 10:25 PM
Use below syntax on mapper-
$reason.substring($reason.indexOf(โ{โ),$reason.length).split(โ,โ)[1].toString()
โ07-11-2018 08:38 AM
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.