Skip to content

Commit

Permalink
Fixed error handling on RishkaVM::loadFile() on VGA shell example.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed May 13, 2024
1 parent 084c246 commit c4b263b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions examples/vga_shell/vga_shell.ino
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,20 @@ void loop() {

// Attempt to load specified file into Rishka virtual machine
if(!vm->loadFile(tokens[0])) {
char message[50];

// If loading file fails, print error message and return
sprintf(message, "Failed to \e[94mload\e[97m specified file: %s", tokens[0]);
vm->panic(message);
Terminal.println("Failed to \e[94mload\e[97m specified file: " +
String(tokens[0]));

// Free all tokens in memory
for(int i = 0; i < 10; i++)
free(tokens[i]);

// Reset Rishka virtual machine for next execution
vm->reset();

// Print prompt
Terminal.print(String("\e[32m[\e[97m") +
vm->getWorkingDirectory() + "\e[97m\e[32m]~\e[97m ");
vm->reset();

return;
}

Expand Down

0 comments on commit c4b263b

Please sign in to comment.