f851d8b8f2
Electron desktop application for Neverwinter Nights module development. Clone, edit, build, and run a complete Layonara NWNX server with only Docker required. - React 19 + Vite frontend with Monaco editor and NWScript LSP - Node.js + Express backend managing Docker sibling containers - Electron shell with Docker availability check and auto-setup - Builder image auto-builds on first use from bundled Dockerfile - Cross-platform: Windows (.exe), macOS (.dmg), Linux (.AppImage) - Gitea Actions CI for automated release builds
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import { Component } from "react";
|
|
import type { ReactNode, ErrorInfo } from "react";
|
|
import { ErrorDisplay } from "./ErrorDisplay";
|
|
|
|
interface Props {
|
|
children: ReactNode;
|
|
}
|
|
|
|
interface State {
|
|
hasError: boolean;
|
|
error: Error | null;
|
|
}
|
|
|
|
export class ErrorBoundary extends Component<Props, State> {
|
|
constructor(props: Props) {
|
|
super(props);
|
|
this.state = { hasError: false, error: null };
|
|
}
|
|
|
|
static getDerivedStateFromError(error: Error): State {
|
|
return { hasError: true, error };
|
|
}
|
|
|
|
componentDidCatch(error: Error, info: ErrorInfo) {
|
|
console.error("ErrorBoundary caught:", error, info);
|
|
}
|
|
|
|
render() {
|
|
if (this.state.hasError && this.state.error) {
|
|
return (
|
|
<div
|
|
style={{
|
|
display: "flex",
|
|
height: "100%",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
padding: "2rem",
|
|
backgroundColor: "var(--forge-bg)",
|
|
}}
|
|
>
|
|
<div style={{ width: "100%", maxWidth: "32rem" }}>
|
|
<ErrorDisplay
|
|
title="Render Error"
|
|
message={this.state.error.message}
|
|
fullLog={this.state.error.stack}
|
|
onRetry={() => this.setState({ hasError: false, error: null })}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
return this.props.children;
|
|
}
|
|
}
|