Why is upload:content:error throwing Faults?

If you call i.e.

Fault* fault = nil;

id result = [backendless.fileService upload:filename content:data error:&fault]; on my iPhone I expect any potential errors to be returned in the “fault” variable. Instead the file service throws an exception which I must handle with a try/catch. This is really not the ios-way imo.

The error above I think is thrown because the file already exists (though it just says FAULT = ‘400’ [HTTP 400] <bad request>)

You get the same issue if calling:

[backendless.persistenceService save:task error:&fault];

and have forgotten to login and have set security to not allow Unauthorized users. Same here, I’d expect the fault returned in error and not a fault thrown…

Hi Jonas,

You are correct, this is not what should’ve happened. Any errors should be delivered to the fault object. I opened an internal ticket and we will look into it.

Thank you for reporting this.

Regards,
Mark

Hi Jonas,

There is a method which controls how the errors are delivered to your app (via fault or by throwing the exception. If you make the following call, then all errors will be delivered to the fault objects:

[backendless setThrowException:NO];

We made a change to route errors to faults by default, it will be in the next build of the SDK, but for now you can use the method above.

Regards,
Mark