From 894e67863dbb89a4819e825fcdf7117021082b2a Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Tue, 24 Jun 2025 13:29:50 +0200 Subject: Replace leaflet for maplibre, use react-router in framework mode --- src/frontend/app/ErrorBoundary.tsx | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/frontend/app/ErrorBoundary.tsx (limited to 'src/frontend/app/ErrorBoundary.tsx') diff --git a/src/frontend/app/ErrorBoundary.tsx b/src/frontend/app/ErrorBoundary.tsx new file mode 100644 index 0000000..5c877b7 --- /dev/null +++ b/src/frontend/app/ErrorBoundary.tsx @@ -0,0 +1,46 @@ +import React, { Component, type ReactNode } from 'react'; + +interface ErrorBoundaryProps { + children: ReactNode; +} + +interface ErrorBoundaryState { + hasError: boolean; + error: Error | null; +} + +class ErrorBoundary extends Component { + constructor(props: ErrorBoundaryProps) { + super(props); + this.state = { + hasError: false, + error: null + }; + } + + static getDerivedStateFromError(error: Error): ErrorBoundaryState { + return { + hasError: true, + error + }; + } + + componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { + console.error("Uncaught error:", error, errorInfo); + } + + render() { + if (this.state.hasError) { + return <> +

Something went wrong.

+
+          {this.state.error?.stack}
+        
+ ; + } + + return this.props.children; + } +} + +export default ErrorBoundary; -- cgit v1.3