ブラウザ版でhead.txt、kanri.txtの取得を失敗した際に該当箇所にエラー文章を表示

This commit is contained in:
konkon-fox 2023-10-16 22:33:07 +09:00
parent c29b659853
commit c88fbba6d5
2 changed files with 4 additions and 2 deletions

View File

@ -35,7 +35,7 @@ if (document.getElementById('kokuti')) {
async function getLocalHtml (targetId, targetFile, isShiftJIS) {
try{
const response = await fetch(targetFile, {cache: 'no-store'});
if(!response.ok) throw new Error();
if(!response.ok) throw new Error('response error');
if(isShiftJIS){
const arrayBuffer = await response.arrayBuffer();
const utf8Text = arrayBufferToUtf8(arrayBuffer);
@ -46,6 +46,7 @@ async function getLocalHtml (targetId, targetFile, isShiftJIS) {
}
}catch(e){
console.error(e);
document.getElementById(targetId).innerHTML += 'ファイルの取得に失敗しました。';
}
}

View File

@ -86,7 +86,7 @@ if (document.getElementById('kokuti')) {
async function getLocalHtml (targetId, targetFile, isShiftJIS) {
try{
const response = await fetch(targetFile, {cache: 'no-store'});
if(!response.ok) throw new Error();
if(!response.ok) throw new Error('response error');
if(isShiftJIS){
const arrayBuffer = await response.arrayBuffer();
const utf8Text = arrayBufferToUtf8(arrayBuffer);
@ -97,6 +97,7 @@ async function getLocalHtml (targetId, targetFile, isShiftJIS) {
}
}catch(e){
console.error(e);
document.getElementById(targetId).innerHTML += 'ファイルの取得に失敗しました。';
}
}