Skip to content

Commit

Permalink
Fix error handling for fetch error #85
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Jan 6, 2024
1 parent 2ca272e commit 0159cd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/core/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const invoke = async () => {
try {
response = await fetch(location.href);
} catch (e) {
updateRibbon(e.message, [""]);
if (location.href.startsWith("file://")) {
updateRibbon(res("cannotFetchLocalPdf"), [""]);
} else {
updateRibbon(e.message, [""]);
}
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/core/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const resources = {
downloadingPdf: "📘ダウンロード中...",
preparingPdf: "📘PDFビューア準備中...",
nonPdf: "PDFファイルではないようです。処理を中断しました。",
cannotFetchLocalPdf:
"⛔Mouse DictionaryはローカルにあるPDFファイル上では起動できません。オプション画面から開けるPDFビューアをご利用ください。",
},
en: {
continueProcessingPdf:
Expand All @@ -23,6 +25,7 @@ const resources = {
downloadingPdf: "📘Downloading...",
preparingPdf: "📘Preparing PDF viewer...",
nonPdf: "This is not a PDF document.",
cannotFetchLocalPdf: "⛔Mouse Dictionary can't launch on local PDFs. Use the PDF viewer from the options screen.",
},
};

Expand Down

0 comments on commit 0159cd8

Please sign in to comment.