Try, Catch block - catching error "Network Error"

The block calls a Backendless API. Does this mean there is a network error with Backendless? We’re getting this a few times a day, and I’m unsure what to make of it or how to resolve it.

image

Do you get the actual email sent in the catch section? If you do, the only suspect would be the addSeller method in the sellers API service. I recommend adding more logging in the service’s method to see what the root cause is.

I do get the emails. I want to know right when errors are taking place.

The addSeller method has try/catch blocks with email notifications, and I’m not getting an error emails from there.

Anywhere I make an external API call, I have those wrapped in try/catch blocks with email notifications of errors, which is why this doesn’t make sense to me. If there are errors in the API method, I should also have notifications about those errors.

In the logic you shared in the screenshot, the API service invocation is the only place where a network request would be made.

Is there a chance the call to the addSeller method is failing and throwing the error, or do you think the error is only coming from logic in the addSeller method?

Thanks,
Tim

It is either coming from within of addSeller OR from the actual call of addSeller. One way to find out is to add a log entry right before and right after the API service invocation.

Like this (with details completed) -

image

I have to admit I’m not clear what this will do. If the error is from the call, or in the call, it will error out either way and not make the second log call, or is that not right?

Tim

If the second Log a message doesn’t show up in the log, it means it was never reached, thus confirming that the error is with the API service invocation.

You still need to add some meaningful message to the “log a message” blocks.

If there was an error in the API, wouldn’t that also not trip the second log block?

If the try/catch is erroring, which we know it is, because I am getting the error emails, something must be throwing the error, right?

Tim

Yes, something must be throwing the error. You need to figure out what it is. The error could be coming from:

  1. inside of the API service
  2. when calling the API service.

If it is (1), further debugging should be happening in the API service. If it is (2), then there must be something related to how the service is invoked, i.e. it may have something to do with the argument passed into the data argument.