Skip to content

Commit

Permalink
fix: catch global error
Browse files Browse the repository at this point in the history
  • Loading branch information
tzuyi0817 committed Jun 17, 2024
1 parent 445d605 commit c15cd7d
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/locales/ar-SA.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "تعال وأنشئ ملفًا جديدًا",
"deleted_projects": "سيتم عرض العناصر المحذوفة هنا",
"encryption_file": "تعيين كلمة مرور لحماية ملف PDF الخاص بك",
"error_occurred": "حدث خطأ غير معروف، يرجى تحديث الصفحة والمحاولة مرة أخرى",
"file_archived_success": "تمت أرشفة الملف بنجاح",
"file_created_success": "تم إنشاء الملف بنجاح",
"file_delete_success": "تم حذف الملف بنجاح",
Expand Down
1 change: 1 addition & 0 deletions src/locales/da-DK.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Kom og opret en ny fil",
"deleted_projects": "Slettede elementer vises her",
"encryption_file": "Angiv en adgangskode for at beskytte din PDF-fil",
"error_occurred": "Der opstod en ukendt fejl, venligst opdater siden og prøv igen",
"file_archived_success": "Fil arkiveret med succes",
"file_created_success": "Fil oprettet med succes",
"file_delete_success": "Fil slettet med succes",
Expand Down
1 change: 1 addition & 0 deletions src/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Lassen Sie uns eine neue Datei erstellen",
"deleted_projects": "Gelöschte Elemente werden hier angezeigt",
"encryption_file": "Legen Sie ein Passwort fest, um die PDF-Datei zu schützen",
"error_occurred": "Ein unbekannter Fehler ist aufgetreten. Bitte aktualisieren Sie die Seite und versuchen Sie es erneut.",
"file_archived_success": "Datei erfolgreich archiviert",
"file_created_success": "Datei erfolgreich erstellt",
"file_delete_success": "Datei erfolgreich gelöscht",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Come and create a new file",
"deleted_projects": "Deleted items will be displayed here",
"encryption_file": "Set a password to protect your PDF file",
"error_occurred": "An unknown error occurred. Please refresh the page and try again",
"file_archived_success": "File archived successfully",
"file_created_success": "File created successfully",
"file_delete_success": "File deleted successfully",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Ven y crea un nuevo archivo",
"deleted_projects": "Los elementos eliminados se mostrarán aquí",
"encryption_file": "Configure una contraseña para proteger su archivo PDF",
"error_occurred": "Ocurrió un error desconocido. Por favor, refresca la página y vuelve a intentarlo",
"file_archived_success": "Archivo archivado exitosamente",
"file_created_success": "Archivo creado exitosamente",
"file_delete_success": "Archivo eliminado exitosamente",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fi-FI.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Tule ja luo uusi tiedosto",
"deleted_projects": "Poistetut kohteet näytetään täällä",
"encryption_file": "Aseta salasana suojataksesi PDF-tiedostosi",
"error_occurred": "Tapahtui tuntematon virhe. Päivitä sivu ja yritä uudelleen",
"file_archived_success": "Tiedosto arkistoitu onnistuneesti",
"file_created_success": "Tiedosto luotu onnistuneesti",
"file_delete_success": "Tiedosto poistettu onnistuneesti",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Créons un nouveau fichier",
"deleted_projects": "Les éléments supprimés apparaîtront ici",
"encryption_file": "Définir un mot de passe pour protéger le fichier PDF",
"error_occurred": "Une erreur inconnue s'est produite. Veuillez rafraîchir la page et réessayer",
"file_archived_success": "Archivage du fichier réussi",
"file_created_success": "Création du fichier réussie",
"file_delete_success": "Suppression du fichier réussie",
Expand Down
1 change: 1 addition & 0 deletions src/locales/he-IL.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "בואו וצור קובץ חדש",
"deleted_projects": "פריטים שנמחקו יופיעו כאן",
"encryption_file": "קבע סיסמה להגנה על קובץ ה-PDF שלך",
"error_occurred": "אירעה שגיאה לא ידועה, נא לרענן את הדף ולנסות שוב",
"file_archived_success": "הקובץ הועבר לארכיון בהצלחה",
"file_created_success": "הקובץ נוצר בהצלחה",
"file_delete_success": "הקובץ נמחק בהצלחה",
Expand Down
1 change: 1 addition & 0 deletions src/locales/hi-IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "आओ और नई फाइल बनाएं",
"deleted_projects": "हटाए गए आइटम यहां प्रदर्शित होंगे",
"encryption_file": "अपनी PDF फ़ाइल की सुरक्षा के लिए पासवर्ड सेट करें",
"error_occurred": "एक अज्ञात त्रुटि हुई है, कृपया पृष्ठ को रीफ्रेश करें और पुनः प्रयास करें",
"file_archived_success": "फ़ाइल सफलतापूर्वक आर्काइव की गई",
"file_created_success": "फ़ाइल सफलतापूर्वक बनाई गई",
"file_delete_success": "फ़ाइल सफलतापूर्वक हटाई गई",
Expand Down
1 change: 1 addition & 0 deletions src/locales/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Vieni a creare un nuovo file",
"deleted_projects": "Gli elementi eliminati saranno visualizzati qui",
"encryption_file": "Imposta una password per proteggere il tuo file PDF",
"error_occurred": "Si è verificato un errore sconosciuto. Si prega di aggiornare la pagina e riprovare",
"file_archived_success": "File archiviato con successo",
"file_created_success": "File creato con successo",
"file_delete_success": "File eliminato con successo",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "新しいファイルを作成しましょう",
"deleted_projects": "削除されたアイテムはここに表示されます",
"encryption_file": "PDFファイルを保護するためのパスワードを設定します",
"error_occurred": "不明なエラーが発生しました。ページをリフレッシュして再試行してください",
"file_archived_success": "ファイルのアーカイブに成功しました",
"file_created_success": "ファイルの作成に成功しました",
"file_delete_success": "ファイルの削除に成功しました",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "새 파일을 만듭니다",
"deleted_projects": "삭제된 항목은 여기에 표시됩니다",
"encryption_file": "PDF 파일을 보호할 비밀번호를 설정하세요",
"error_occurred": "알 수 없는 오류가 발생했습니다. 페이지를 새로고침한 후 다시 시도해주세요",
"file_archived_success": "파일 보관 성공",
"file_created_success": "파일 생성 성공",
"file_delete_success": "파일 삭제 성공",
Expand Down
1 change: 1 addition & 0 deletions src/locales/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Kom en maak een nieuw bestand aan",
"deleted_projects": "Verwijderde items worden hier weergegeven",
"encryption_file": "Stel een wachtwoord in om uw PDF-bestand te beschermen",
"error_occurred": "Er is een onbekende fout opgetreden. Vernieuw de pagina en probeer opnieuw",
"file_archived_success": "Bestand succesvol gearchiveerd",
"file_created_success": "Bestand succesvol aangemaakt",
"file_delete_success": "Bestand succesvol verwijderd",
Expand Down
1 change: 1 addition & 0 deletions src/locales/no-NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Kom og opprett en ny fil",
"deleted_projects": "Slettede elementer vil vises her",
"encryption_file": "Angi et passord for å beskytte PDF-filen din",
"error_occurred": "Det oppstod en ukjent feil. Vennligst oppdater siden og prøv igjen",
"file_archived_success": "Fil arkivert vellykket",
"file_created_success": "Fil opprettet vellykket",
"file_delete_success": "Fil slettet vellykket",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Przyjdź i utwórz nowy plik",
"deleted_projects": "Usunięte elementy będą wyświetlane tutaj",
"encryption_file": "Ustaw hasło, aby chronić plik PDF",
"error_occurred": "Wystąpił nieznany błąd. Proszę odświeżyć stronę i spróbować ponownie",
"file_archived_success": "Plik został pomyślnie zarchiwizowany",
"file_created_success": "Plik został pomyślnie utworzony",
"file_delete_success": "Plik został pomyślnie usunięty",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Venha e crie um novo arquivo",
"deleted_projects": "Itens excluídos serão exibidos aqui",
"encryption_file": "Defina uma senha para proteger seu arquivo PDF",
"error_occurred": "Ocorreu um erro desconhecido. Por favor, atualize a página e tente novamente",
"file_archived_success": "Arquivo arquivado com sucesso",
"file_created_success": "Arquivo criado com sucesso",
"file_delete_success": "Arquivo excluído com sucesso",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Приходите и создайте новый файл",
"deleted_projects": "Удаленные элементы будут отображаться здесь",
"encryption_file": "Установите пароль для защиты вашего файла PDF",
"error_occurred": "Произошла неизвестная ошибка. Пожалуйста, обновите страницу и попробуйте снова",
"file_archived_success": "Файл успешно архивирован",
"file_created_success": "Файл успешно создан",
"file_delete_success": "Файл успешно удален",
Expand Down
1 change: 1 addition & 0 deletions src/locales/sv-SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Kom och skapa en ny fil",
"deleted_projects": "Borttagna objekt visas här",
"encryption_file": "Ange ett lösenord för att skydda din PDF-fil",
"error_occurred": "Ett okänt fel inträffade. Vänligen uppdatera sidan och försök igen",
"file_archived_success": "Filen har arkiverats",
"file_created_success": "Filen har skapats",
"file_delete_success": "Filen har raderats",
Expand Down
1 change: 1 addition & 0 deletions src/locales/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "Gel ve yeni bir dosya oluştur",
"deleted_projects": "Silinmiş öğeler burada görüntülenecektir",
"encryption_file": "PDF dosyanızı korumak için bir şifre belirleyin",
"error_occurred": "Bilinmeyen bir hata oluştu. Lütfen sayfayı yenileyip tekrar deneyin",
"file_archived_success": "Dosya başarıyla arşivlendi",
"file_created_success": "Dosya başarıyla oluşturuldu",
"file_delete_success": "Dosya başarıyla silindi",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "让我们创建一个新文件",
"deleted_projects": "已删除的项目将显示在此处",
"encryption_file": "设置密码以保护 PDF 文件",
"error_occurred": "发生未知错误,请刷新页面重新尝试",
"file_archived_success": "文件成功归档",
"file_created_success": "文件创建成功",
"file_delete_success": "文件删除成功",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"create_file": "快來建立新檔吧",
"deleted_projects": "刪除的項目會顯示在這裡",
"encryption_file": "設置一個密碼來保護你的PDF檔案",
"error_occurred": "發生未知的錯誤, 請刷新頁面重新嘗試",
"file_archived_success": "檔案封存成功",
"file_created_success": "檔案建立成功",
"file_delete_success": "檔案刪除成功",
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '@/style/index.css';
import '@/style/tailwind.css';
import App from '@/App.vue';
import router from '@/router';
import errorHandlerPlugin from '@/plugins/errorHandler';
import i18NPlugin from '@/plugins/i18n';
import idbPlugin from '@/plugins/idb';

Expand All @@ -18,4 +19,5 @@ app.use(pinia);
app.use(router);
app.use(idbPlugin);
app.use(i18NPlugin);
app.use(errorHandlerPlugin);
app.mount('#app');
16 changes: 16 additions & 0 deletions src/plugins/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { App } from 'vue';
import i18n from '@/plugins/i18n';
import toast from '@/utils/toast';

export default {
install(app: App) {
app.config.errorHandler = (err, vm, info) => {
const { t } = i18n.global;

console.error('Global error handling:', err);
console.error('The error occurred in:', vm);
console.error('The error message:', info);
toast.showToast(t('prompt.error_occurred'), 'error');
};
},
};

0 comments on commit c15cd7d

Please sign in to comment.