Skip to content

Commit

Permalink
CONNECT_AND_EXPORT_TEXTも
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Jun 22, 2024
1 parent cbf0719 commit d6ac501
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/helpers/fileHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ import { ResultError } from "@/type/result";

/** ファイル書き込み時のエラーメッセージを生成する */
export function generateWriteErrorMessage(writeFileResult: ResultError) {
if (!writeFileResult.code) {
return `何らかの理由で失敗しました。${writeFileResult.message}`;
}
const code = writeFileResult.code.toUpperCase();
const code = writeFileResult.code?.toUpperCase();

if (code.startsWith("ENOSPC")) {
if (code?.startsWith("ENOSPC")) {
return "空き容量が足りません。";
}

if (code.startsWith("EACCES")) {
if (code?.startsWith("EACCES")) {
return "ファイルにアクセスする許可がありません。";
}

if (code.startsWith("EBUSY")) {
if (code?.startsWith("EBUSY")) {
return "ファイルが開かれています。";
}

if (code?.startsWith("ENOENT")) {
return "ファイルが見つかりません。";
}

return `何らかの理由で失敗しました。${writeFileResult.message}`;
}
6 changes: 5 additions & 1 deletion src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,11 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
});
if (!result.ok) {
window.backend.logError(result.error);
return { result: "WRITE_ERROR", path: filePath };
return {
result: "WRITE_ERROR",
path: filePath,
errorMessage: generateWriteErrorMessage(new ResultError(result)),
};
}

return { result: "SUCCESS", path: filePath };
Expand Down

0 comments on commit d6ac501

Please sign in to comment.