Websites Navigation: Airbit | Shop | m-shell.net
Languages: EN | DE

m Runtime Errors (Exceptions)

Uncatched exceptions in m scripts will terminate the script, and the exception will be shown as an error message, followed by a list of the nested function calls leading to the error. In a script, selecting a function call will open the corresponding source and show the location of the call or statement leading to the exception.

In an executable, the source locations are not available.

To demonstrate the handling of uncatched exceptions, let's assume we forgot in our SMS service to test for the user cancelling the dialog with the choice of messages to edit, i.e. the ui.list() call returning null. Open the MyDB module, and comment out the line checking for returned value being null (by putting two slashes in front of it):

    i=ui.list(list);
    //if i=null then break end;
    i=i[0];

Now save the modified module, and start SmsService. After choosing →Edit from the menu, cancel the selection list. The following message should appear:

   
Series 60 sample screen
UIQ sample screen

The exception ExcNotArray indicates that an expression (or variable) which was not an array was accessed as an array, but it was no array (we know it was null).

Confirming the message dialog shows the list of nested function calls which produced the error. The topmost is the function where the error occured, the last is normally .<main>, i.e. the statements of the main part of the main script (the "module" with empty name).

   
Series 60 sample screen
UIQ sample screen

Select mydb.edit. This will show the corresponding module source, with the cursor conveniently placed at the location of the error[5]:

   
Series 60 sample screen
UIQ sample screen

Selecting Edit→Error Trace will display the last error trace again, so you can pick .<main> to show the location where mydb.edit was called:

   
Series 60 sample screen
UIQ sample screen

Following the traceback should help you getting a better understanding of the conditions which lead to the error.

Note that in standalone applications, uncatched runtime errors will simply show a message, and terminate the application.


© 2004-2011 airbit AG, CH-8008 Zürich
Document AB-M-TUT-887
mShell Home  > Documentation  > Manuals