Add centralized error handler for sync Vue app

This commit is contained in:
Eli Ribble 2026-05-08 23:33:49 +00:00
parent da90401b2d
commit 01f35b603e
No known key found for this signature in database
3 changed files with 83 additions and 1 deletions

View file

@ -0,0 +1,29 @@
import { ref } from "vue";
interface ErrorState {
hasError: boolean;
message: string;
timestamp: Date;
}
const globalError = ref<ErrorState | null>(null);
export function useErrorHandler() {
const setError = (error: Error) => {
globalError.value = {
hasError: true,
message: error.message,
timestamp: new Date(),
};
};
const errorClear = () => {
globalError.value = null;
};
return {
error: globalError,
setError,
errorClear,
};
}