HubAPI / components /ui /error-boundary.tsx
samirhosninet's picture
feat: complete HUBAPI overhaul (Security, i18n RTL, Dark/Light Mode, A11y & Performance fixes)
587459d
Raw History Blame Contribute Delete
1.55 kB
"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;
}
}