Tinkerforge / esp32-firmware

Firmwares for ESP32 Brick and ESP32 Ethernet Brick (including firmwares for WARP/WARP2 Charger, WARP Energy Manager)
https://www.tinkerforge.com/en/doc/Hardware/Bricks/ESP32_Ethernet_Brick.html
23 stars 20 forks source link

web: Use wrapper component to handle sub-page render errors. #274

Open rtrbt opened 10 months ago

rtrbt commented 10 months ago
class Catcher extends Component {
    state :{ error: Error } = {error: null};

    componentDidCatch(error: Error) {
        this.setState({ error: error });
    }

    render(props: {children: ComponentChildren}, state: { error: Error }) {
        if (state.error != null) {
            return <pre>{state.error.stack}</pre>;
        }
        return props.children;
    }
}

example usage:

render(<Catcher><Mqtt/></Catcher>, $('#mqtt')[0])

Maybe wait until the site skeleton is ported over to preact to not modify every page render call twice.

Explain what happened and how to report bugs on the error page. Maybe mention the recovery page (at least if rendering the firmware update page fails)