Spaces:
Paused
Paused
File size: 1,548 Bytes
587459d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | "use client";
import React, { Component, ErrorInfo, ReactNode } from "react";
import { AlertTriangle } from "lucide-react";
interface Props {
children: ReactNode;
fallback?: ReactNode;
}
interface State {
hasError: boolean;
}
export class ErrorBoundary extends Component<Props, State> {
public state: State = {
hasError: false
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public static getDerivedStateFromError(_error: Error): State {
return { hasError: true };
}
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
console.error("Uncaught error in component boundary:", error, errorInfo);
}
public render() {
if (this.state.hasError) {
return this.props.fallback || (
<div className="mx-auto my-8 max-w-lg p-6 rounded-lg border border-destructive/20 bg-destructive/5 backdrop-blur-md text-center font-mono space-y-4 shadow-[0_0_30px_rgba(239,68,68,0.05)]">
<div className="flex justify-center text-destructive">
<AlertTriangle className="w-8 h-8 animate-pulse" />
</div>
<h3 className="text-xs font-bold uppercase tracking-widest text-foreground">
{"// RUNTIME EXCEPTION CAUGHT"}
</h3>
<p className="text-[10px] text-muted-foreground/80 leading-relaxed max-w-sm mx-auto">
A secure runtime isolation boundary captured an exception in this module. The rest of the platform remains online.
</p>
</div>
);
}
return this.props.children;
}
}
|