@@ -954,12 +954,20 @@ void jsiSemiInit(bool autoLoad, JsfFileName *loadedFilename) {
954954#ifdef ESP8266
955955 jshPrintBanner ();
956956#endif
957+ #ifndef SAVE_ON_FLASH
958+ if (jsfFindFile (jsfNameFromString ("ERROR" ),NULL ))
959+ jsiConsolePrint ("\nAn Uncaught Error has been saved to Storage. Please type:\n"
960+ " require('Storage').read('ERROR') to view it\n"
961+ " require('Storage').erase('ERROR') to clear it\n" );
962+ #endif
963+
957964 }
958965#ifdef USE_TERMINAL
959966 if (consoleDevice != EV_TERMINAL ) // don't spam the terminal
960967#endif
961968 jsiConsolePrint ("\n" ); // output new line
962969 inputLineRemoved = true; // we need to put the input line back...
970+
963971 }
964972
965973#ifdef BANGLEJS // On Bangle.js if Storage is corrupt, show a recovery menu
@@ -1289,13 +1297,31 @@ void jsiCheckErrors() {
12891297 jsiConsoleRemoveInputLine ();
12901298 jsiConsolePrintf ("Uncaught %v\n" , exception );
12911299 reportedError = true;
1300+ #ifndef SAVE_ON_FLASH
1301+ JsVar * exceptionString = NULL ;
1302+ if ((!jsfGetFlag (JSF_NO_ERRORS_SAVE )) && !jsfFindFile (jsfNameFromString ("ERROR" ),NULL ))
1303+ exceptionString = jsvAsString (exception );
1304+ #endif
1305+
12921306 if (jsvIsObject (exception )) {
12931307 JsVar * stackTrace = jsvObjectGetChildIfExists (exception , "stack" );
12941308 if (stackTrace ) {
12951309 jsiConsolePrintStringVar (stackTrace );
1310+ #ifndef SAVE_ON_FLASH
1311+ if (exceptionString ) {
1312+ jsvAppendCharacter (exceptionString , '\n' );
1313+ jsvAppendStringVarComplete (exceptionString , stackTrace );
1314+ }
1315+ #endif
12961316 jsvUnLock (stackTrace );
12971317 }
12981318 }
1319+ #ifndef SAVE_ON_FLASH
1320+ if (exceptionString ) {
1321+ jsfWriteFile (jsfNameFromString ("ERROR" ), exceptionString , JSFF_NONE , 0 , 0 );
1322+ jsvUnLock (exceptionString );
1323+ }
1324+ #endif
12991325 }
13001326 jsvUnLock (exception );
13011327 if (jspIsInterrupted ()
0 commit comments