CSCI-SHU-410-SE-Project / Deskulpt

Deskulpt (Desktop + Sculpt, pronounced /'deskʌlpt/), a cross-platform desktop customization tool.
https://csci-shu-410-se-project.github.io/Deskulpt/
MIT License
2 stars 0 forks source link

BUG Deskulpt can't handle syntax error in widget js code #9

Closed Xinyu-Li-123 closed 7 months ago

Xinyu-Li-123 commented 7 months ago

When there is a syntax error in the widget js code, Deskulpt will crash. This happens at commit 442cf1, the head commit when I submit this issue. Below is a minimal example to reproduce this bug.

const React = window.__DESKULPT__.defaultDeps.React;

// Syntax error here, misspell "const" as "conts", will crash Deskulpt
conts bannerText = "My Simple Banner";

function Banner() {
  return (
    <div>
      <h1>{bannerText}</h1>
    </div>
  );
}

export default {
  render: () => <Banner />,
};

And is the error message produced when Deskulpt crashes. It happens when I add this widget to the widgets folder and render. I run Deskulpt with npm run tauri dev.

error: Expected ';', '}' or <eof>
 --> \\?\C:\Users\eiger\AppData\Roaming\com.tauri.deskulpt\widgets\ok-simple-banner\src\App.jsx:3:7
  |
3 | conts bannerText = "My Simple Banner";
  | ----- ^^^^^^^^^^
  | |
  | This is the expression part of an expression statement   

thread 'main' panicked at src\bundler.rs:171:21:
FATAL: Failed to parse module
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[0406/173441.713:ERROR:window_impl.cc(121)] Failed to unregister class Chrome_WidgetWin_0. Error = 0

@Charlie-XIAO @ROMEEZHOU You might want to check this out since we are writing tests for bundler this week

Charlie-XIAO commented 7 months ago

The error is currently emitted into the console, seems I forgot to change that. I need to figure out how to emit as a string though.