What is an Application.OnError and How We Handle It?


What is Application.OnError?

Negative paths in app development can be easily missed by the app developer and in most of the cases developer feels it is a burden to carry on. With using the generic error handling in Smartface App Studio enables the developer to handle those negative paths only at once, define a generic approach for it. It is possible to customize it according to the network object (which means which case it is), what is the response code, user friendly messages received from server, etc…

This generic onError event captures only other unhandled error cases, such as server responds an http error code and this is not handled with the server error of the network object or Javascript executes an invalid statement which is not in a try catch statement, all could be handled and managed.

This is same for Javascript cases; this interpreted programming language is easy to make mistakes. On design-time the most effective way is making a syntax check, but programmers know that it is not enough. Run-time errors can occur any time, and it is not easily realized by the developer and after the error developer tries to figure out why the code is not working.

And What We Did?

Smartface App Studio now provides a new feature which will speed up the mobile app development. From now on it is easier to handle errors in the application: Run-time Javascript Errors, Network Errors, and SQL Errors. They all could be managed from a single location.

This onError event is flexible, it adapts to case about what is the error; developer does not need to change his or her development habits. If it is a network error, the parameter is network error object, if it is a Javascript error (exception) the parameter is the native Javascript Error object which caught on try-catch statements.

BTW: Here is our Tips & Tricks document and some code examples about Application.OnError statement.