Hello
I used the data , files and relation ship using asynchronous methods and all look great.
I have decided to go with synchronous methods as I need to execute things sequentially in an AsyncTask
My question is about the return values. It is pretty organized and well documented with the asynchronous calls as pretty much it is either success or you get backendlessfault which you can get more info about .
But for synchronous calls , I found that data saving gives you map , while relationship gives you an integer while files don’t return anything but throws an exception you have to handle
How do I know what each one error situation should do ? Basically how do I know if
Yes I checked that. It only refers to situations where BackendFaultException is thrown. Only the Data API with method “save” throws that type of exception (from the above code snippet).
For example, the Files ->Upload method throws Exception (not BackendFaultException)
The Data->SetRelation method does not throw an exception at all. It just returns an integer specifying the number of relations but I don’t know if this returned value will hold another info such as errorCode in case of errors
If all the synchronous methods had the BackendlessFault Exception then that would’ve been consistent but it seems every method has its error handling way (and thus my question)
Actually ALL synchronous methods can potentially throw BackendlessException. Not all of them declare it for the reason that BackendlessException extends RuntimeException, thus it is not checked:
OHHH That helps a lot then. Because when I was hovering over the method “setRelation” the documentation did not say that it throws any type of exception.
So I can surround the Files ->Upload and Data->SetRelation methods with ty/catch block for th BackendlessException which will catch errors if something goes wrong, correct?
Java does not require methods to declare that they can throw runtime exceptions - that’s why you didn’t see it there. But if there is an error coming back from the server, it will be delivered through BackendlessException.