Skip to main content
1-Visitor
July 12, 2017
Question

Error managment in services

  • July 12, 2017
  • 2 replies
  • 1712 views

Hi,

I have a service A on a thing which is calling a service B on a utilityThing.

This service B return an infotable

Some time, in internal process of B, we have an error which has to be propagate to A.

How to do that ?

I try with a javascript "throw" but it seems to be intercepted by plateform as in the try catch in A I see a JavaException.

Best regards

Stéphane

2 replies

20-Turquoise
July 12, 2017

Could you please provide more details? I apologize for the misunderstanding, the description is not too clear. Does the error in B occur as a result of a service calling, i.e infotable is no longer returned? You may try catch in A around the service B, and then ensure your result is outside of that .

1-Visitor
July 13, 2017

Hi Stephane,

You can use throw "text";  // -- I think it's not officially supported anyway, I've used in the past but I'm removing almost everywhere on my code

It works, but I recommend you to minimize the times on your programing blocks when a Exception occurs, as it's super slow to process. For instance if you Iterate over N-objects and you relay on a try{}catch inside the loop to catch errors if you have many of them it will be super slow to execute.

If you can, better you prevent calling B if you can know in advance that there will be an error ( param checking and alike ) and/or detect error on B and return a special case Infotable and not throwing an exception.