How can I use the Screen Error Occurred

1,480 views
Skip to first unread message

karim fouad

unread,
Apr 25, 2017, 8:20:55 AM4/25/17
to MIT App Inventor Forum
Dear All 


 ? How can I use the Screen Error Occurred  Block Please

zac

unread,
Apr 25, 2017, 8:40:32 AM4/25/17
to MIT App Inventor Forum
What are you trying to accomplish?

For a general case, use a notifier to catch any error occurs.

SteveJG

unread,
Apr 25, 2017, 8:57:23 AM4/25/17
to MIT App Inventor Forum
The Screen Error Occurred block:

ErrorOccurred(component component, text functionName, number errorNumber, text message)
Event raised when an error occurs. Only some errors will raise this condition. For those errors, the system will show a notification by default. You can use this event handler to prescribe an error behavior different than the default.

1) The block may be used to 'trap' errors that occur within the app.  The developer can use this as a debugging tool .  The block can sometimes find out information about the component that is the point of issue, the functionName causing problems, the errorNumber (there are 'standard' error messages that relate to system activities ) or the error message itself.

2) Placing the block on the Designer, without placing any code in the event handler can sometimes suppress the display of error messages when the error is not a fatal error. Placing the block on the Blocks screen does not correct the error. .The use of the block is not a panacea.  The blocks allows a user to determine what error occurred and why.  After learning about the problem in the apps code, use the error handling information to provide code in your blocks to avoid the error ... something like  if a value is < then a certain value, the code following should not be processed.

3) The event handler is a tool.  You can also use it to graciously inform the apps user that there is a serious problem...a bit redundant, but the system messages will also probably appear.

4)  If you elicit an error in your coding and it appears when the code is executed, you can experiment and see for yourself.   Simply assign the various options to a Label component or a Notifier message.
Reply all
Reply to author
Forward
0 new messages