err handl

This commit is contained in:
Irwan Cahyono 2025-08-08 01:02:17 +07:00
parent d0f517a0f9
commit 921de8e19c
3 changed files with 14 additions and 10 deletions

View File

@ -45,7 +45,7 @@
<div>
<img :src="currentFlag" alt="image" class="h-5 w-5 rounded-full object-cover" />
</div>
<div class="text-base font-bold uppercase">{{ store.locale }}</div>
<div v-if="store" class="text-base font-bold uppercase">{{ store.locale }}</div>
<span class="shrink-0">
<icon-caret-down />
</span>
@ -192,7 +192,8 @@
definePageMeta({
layout: 'auth-layout',
});
const store = useAppStore();
// const store = useAppStore();
const store = process.client ? useAppStore() : null;
const { setLocale } = useI18n();
const config = useRuntimeConfig();
const auth = useAuthStore();
@ -202,7 +203,7 @@
appSetting.toggleLanguage(item, setLocale);
};
const currentFlag = computed(() => {
return `/assets/images/flags/${store.locale?.toUpperCase()}.svg`;
return store?.locale ?`/assets/images/flags/${store.locale?.toUpperCase()}.svg` : '';
});
const login = async () => {

10
plugins/error-handler.ts Normal file
View File

@ -0,0 +1,10 @@
// plugins/error-handler.client.ts
export default defineNuxtPlugin(() => {
window.addEventListener('error', (e) => {
console.error('Client-side Error:', e.message)
})
window.addEventListener('unhandledrejection', (e) => {
console.error('Unhandled Promise Rejection:', e.reason)
})
})

View File

@ -1,7 +0,0 @@
import { defineNitroPlugin } from 'nitropack'
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('error', (error, event) => {
console.error('[Nitro Error]', error)
})
})