{"id":693,"date":"2015-04-30T16:24:28","date_gmt":"2015-04-30T23:24:28","guid":{"rendered":"http:\/\/appinventor.pevest.com\/?p=693"},"modified":"2015-04-30T16:24:28","modified_gmt":"2015-04-30T23:24:28","slug":"identifying-the-cause-of-serious-errors","status":"publish","type":"post","link":"https:\/\/coldstreams.com\/appinventor\/2015\/04\/30\/identifying-the-cause-of-serious-errors\/","title":{"rendered":"Identifying the cause of serious errors in App Inventor apps"},"content":{"rendered":"<p>Some times App Inventor 2 apps stop working (well mine sometimes do this, may be your&#8217;s don&#8217;t!)<\/p>\n<p>Besides looking carefully at your blocks code, there are some additional steps that may\u00a0be helpful in identifying the cause of the problem.<\/p>\n<p>1. Check your blocks code very carefully to see if you can spot an error in your program.<\/p>\n<p>2. Add a status message area in the user interface (using the\u00a0<em>Designer<\/em>) and then in your blocks code, add blocks to assign status texts to this message area. Your status message could include a message indicating what section of your code is running, or to display the values of variables in your program.<\/p>\n<p>3. Add a special &#8220;Error handler&#8221; to catch and display information when the program encounters a serious problem. The following section is adapted from my <a href=\"http:\/\/appinventor.pevest.com\/?p=520\">tutorial on basic Bluetooth communications<\/a>.<\/p>\n<p><strong>Error \u00a0Handling<\/strong><\/p>\n<p>For most of our App Inventor apps, we ignore potential errors \u2013 if errors occur, the app stops running and Android displays error messages.<\/p>\n<p>Our app can <em>intercept the error condition<\/em> by adding an <em>error event handler<\/em> to the main screen, <em>Screen1<\/em>. In the Blocks editor, select the <em>Screen1<\/em> component and then select the When <em>Screen1.ErrorOccurred<\/em> event. Drag this to the Blocks editor and then add the following code.<\/p>\n<p>The <em>ErrorOccurred<\/em> event has four parameter values (local variables) that contain information about the error. This error handler displays the\u00a0error values on your device\u00a0screen, rather than immediately shutting down the app.<\/p>\n<p><a href=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/BTServerErrorHandler.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-543\" src=\"http:\/\/appinventor.pevest.com\/wp-content\/uploads\/2015\/01\/BTServerErrorHandler.png\" alt=\"BTServerErrorHandler\" width=\"469\" height=\"261\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>To use this code, add a text label to your user interface &#8211; in the example above, the label has been renamed to <em>lblStatus<\/em>.<\/p>\n<p>There is no guarantee that these error values will identify the specific problem but they may give an indication as to where the problem is occurring in your program!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some times App Inventor 2 apps stop working (well mine sometimes do this, may be your&#8217;s don&#8217;t!) Besides looking carefully at your blocks code, there are some additional steps that may\u00a0be helpful in identifying the cause of the problem. 1. Check your blocks code very carefully to see if you can spot an error in &hellip; <a href=\"https:\/\/coldstreams.com\/appinventor\/2015\/04\/30\/identifying-the-cause-of-serious-errors\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Identifying the cause of serious errors in App Inventor apps<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,10],"tags":[],"class_list":["post-693","post","type-post","status-publish","format-standard","hentry","category-components","category-programming-method"],"_links":{"self":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts\/693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/comments?post=693"}],"version-history":[{"count":0,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/posts\/693\/revisions"}],"wp:attachment":[{"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/media?parent=693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/categories?post=693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coldstreams.com\/appinventor\/wp-json\/wp\/v2\/tags?post=693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}