import { defineComponent, onErrorCaptured, ref } from "vue"; export function withErrorBoundary(WrappedComponent: any) { return defineComponent({ name: `WithErrorBoundary(${WrappedComponent.name})`, render() { if (this.hasError) { return (

500.  Đã xảy ra lỗi.

Máy chủ đang gặp sự cố tạm thời và không thể xử lý yêu cầu của bạn. Vui lòng thử lại sau vài phút.

); } return ; }, setup() { const hasError = ref(false); const error = ref(null); onErrorCaptured((err) => { hasError.value = true; error.value = err as Error; console.error("Error captured in withErrorBoundary:", err); return false; // Prevent further propagation }); return { hasError, error, reset: () => { hasError.value = false; error.value = null; } }; }, }); }