Skip to content

Commit 1263857

Browse files
committed
Ensure we don't try and save errors to Storage if they're from code that's been run from the REPL
1 parent bec9266 commit 1263857

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/jsflash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ bool jsfLoadBootCodeFromFlash(bool isReset) {
14161416
JsVar *code = jsfReadFile(jsfNameFromString(".bootPowerOn"),0,0);
14171417
if (code) {
14181418
jsvUnLock2(jspEvaluateVar(code,0,".bootPowerOn",0), code);
1419-
jsiCheckErrors();
1419+
jsiCheckErrors(false);
14201420
}
14211421
}
14221422
#endif
@@ -1438,15 +1438,15 @@ bool jsfLoadBootCodeFromFlash(bool isReset) {
14381438
JsVar *code = jsfReadFile(jsfNameFromString(filename),0,0);
14391439
if (code) {
14401440
jsvUnLock2(jspEvaluateVar(code,0,filename,0), code);
1441-
jsiCheckErrors();
1441+
jsiCheckErrors(false);
14421442
}
14431443
}
14441444
}
14451445
// Load normal boot code
14461446
JsVar *code = jsfGetBootCodeFromFlash(isReset);
14471447
if (!code) return false;
14481448
jsvUnLock2(jspEvaluateVar(code,0,"boot code",0), code);
1449-
jsiCheckErrors();
1449+
jsiCheckErrors(false);
14501450
return true;
14511451
}
14521452

src/jsinteractive.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ void jsiSoftInit(bool hasBeenReset) {
540540
JsVar *initCode = jsvObjectGetChildIfExists(execInfo.hiddenRoot, JSI_INIT_CODE_NAME);
541541
if (initCode) {
542542
jsvUnLock2(jspEvaluateVar(initCode, 0, "initcode", 0), initCode);
543-
jsiCheckErrors();
543+
jsiCheckErrors(false);
544544
jsvObjectRemoveChild(execInfo.hiddenRoot, JSI_INIT_CODE_NAME);
545545
}
546546

@@ -566,13 +566,13 @@ void jsiSoftInit(bool hasBeenReset) {
566566

567567
// Execute `init` events on `E`
568568
jsiExecuteEventCallbackOn("E", INIT_CALLBACK_NAME, 0, 0);
569-
jsiCheckErrors();
569+
jsiCheckErrors(false);
570570
// Execute the `onInit` function
571571
JsVar *onInit = jsvObjectGetChildIfExists(execInfo.root, JSI_ONINIT_NAME);
572572
if (onInit) {
573573
if (jsiEcho()) jsiConsolePrint("Running onInit()...\n");
574574
jsiExecuteEventCallback(0, onInit, 0, 0);
575-
jsiCheckErrors();
575+
jsiCheckErrors(false);
576576
jsvUnLock(onInit);
577577
}
578578
}
@@ -789,7 +789,7 @@ void jsiSoftKill() {
789789
jsiPacketExit();
790790
// Execute `kill` events on `E`
791791
jsiExecuteEventCallbackOn("E", KILL_CALLBACK_NAME, 0, 0);
792-
jsiCheckErrors();
792+
jsiCheckErrors(false);
793793
// Clear input line...
794794
inputCursorPos = 0;
795795
jsiInputLineCursorMoved();
@@ -1276,7 +1276,7 @@ bool jsiAtEndOfInputLine() {
12761276
return true;
12771277
}
12781278

1279-
void jsiCheckErrors() {
1279+
void jsiCheckErrors(bool wasREPL) {
12801280
if (jsiStatus & JSIS_EVENTEMITTER_INTERRUPTED) {
12811281
jspSetInterrupted(false);
12821282
jsiStatus &= ~JSIS_EVENTEMITTER_INTERRUPTED;
@@ -1573,7 +1573,7 @@ void jsiHandleNewLine(bool execute) {
15731573
}
15741574
jsvUnLock(v);
15751575
}
1576-
jsiCheckErrors();
1576+
jsiCheckErrors(true/*repl*/);
15771577
// console will be returned next time around the input loop
15781578
// if we had echo off just for this line, reinstate it!
15791579
jsiStatus &= ~JSIS_ECHO_OFF_FOR_LINE;
@@ -1695,7 +1695,7 @@ static void jsiPacketProcess() {
16951695
JsVar *result = jspEvaluateExpressionVar(inputLine);
16961696
if (jspHasError()) {
16971697
jsiConsolePrintChar(ASCII_NAK);
1698-
jsiCheckErrors();
1698+
jsiCheckErrors(true/*repl*/);
16991699
} else {
17001700
jsiConsolePrintChar(ASCII_ACK);
17011701
JsVar *v = jswrap_espruino_toJS(result);
@@ -2647,7 +2647,7 @@ bool jsiLoop() {
26472647
// Do general idle stuff
26482648
jsiIdle();
26492649
// check for and report errors
2650-
jsiCheckErrors();
2650+
jsiCheckErrors(false);
26512651

26522652
// If Ctrl-C was pressed, clear the line (unless doing packet transfer)
26532653
if ((execInfo.execute & EXEC_CTRL_C_MASK) && !IS_PACKET_TRANSFER(inputState)) {

src/jsinteractive.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ bool jsiExecuteEventCallbackName(JsVar *obj, const char *cbName, unsigned int ar
6363
/// Utility version of jsiExecuteEventCallback for calling events on global variables
6464
bool jsiExecuteEventCallbackOn(const char *objectName, const char *cbName, unsigned int argCount, JsVar **argPtr);
6565

66-
/// Check for and report/handle interpreter errors (can be called after executing JS code)
67-
void jsiCheckErrors();
66+
/// Check for and report/handle interpreter errors (can be called after executing JS code). If wasREPL we won't save errors to storage as we assume they've been seen
67+
void jsiCheckErrors(bool wasREPL);
6868

6969
/// Create a timeout in JS to execute the given native function (outside of an IRQ). Returns the index
7070
JsVar *jsiSetTimeout(void (*functionPtr)(void), JsVarFloat milliseconds);

0 commit comments

Comments
 (0)