plazbot
Version:
Official Plazbot SDK for creating AI agents for WhatsApp, portals, and developers.
30 lines (29 loc) • 1.17 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Component } from 'react';
export class ErrorBoundary extends Component {
constructor(props) {
super(props);
this.state = { hasError: false, error: null };
}
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
componentDidCatch(error, info) {
console.error('[Plazbot] Error en componente:', error, info);
}
render() {
if (this.state.hasError) {
if (this.props.fallback)
return this.props.fallback;
return (_jsxs("div", { style: {
padding: '16px',
color: '#dc2626',
backgroundColor: '#fef2f2',
borderRadius: '8px',
fontSize: '14px',
fontFamily: 'sans-serif',
}, children: [_jsx("strong", { children: "Error en Plazbot Chat" }), _jsx("p", { style: { margin: '4px 0 0', fontSize: '12px', color: '#991b1b' }, children: this.state.error?.message ?? 'Error desconocido' })] }));
}
return this.props.children;
}
}