Skip to content

Commit 6c0ba82

Browse files
committed
エラーハンドラを関数として分離
1 parent fe7993e commit 6c0ba82

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/utils/errorHandler.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { window } from 'vscode';
2+
import * as nls from 'vscode-nls';
3+
4+
const localize = nls.loadMessageBundle();
5+
6+
export function handleErrorMessage (error: Error) {
7+
switch (error.name) {
8+
case 'QiitaUnauthorizedError':
9+
return window.showErrorMessage(localize('general.failure.unauhtorized', 'リクエストに失敗しました。Qiitaアカウントを認証しているかお確かめの上もう一度お試しください'));
10+
case 'QiitaForbiddenError':
11+
return window.showErrorMessage(localize('general.failure.forbitten', 'リクエストに失敗しました。正しいアカウントにログインしているかをお確かめの上もう一度お試しください'));
12+
case 'QiitaNotFoundError':
13+
return window.showErrorMessage(localize('general.failure.notFound', 'リクエストに失敗しました。指定されたページは存在しないか削除された可能性があります。'));
14+
case 'QiitaRateLimitError':
15+
return window.showErrorMessage(localize('general.failure.rateLimit', 'APIのレートリミットに到達しました。時間をおいてもう一度お試しください。'));
16+
case 'QiitaInternalServerError':
17+
return window.showErrorMessage(localize('general.failure.InternalServerError', '削除に失敗しました。Qiitaのサーバーがダウンしている可能性があります。'));
18+
default:
19+
return window.showErrorMessage(localize('general.failure.fallback', 'ご迷惑をお掛けしてしまい申し訳ございませんが、エラーが発生しました。 バグの可能性がある場合は開発者にご報告いただけると幸いです。\nhttps://github.com/neet/vscode-qiita/issues'));
20+
}
21+
}

0 commit comments

Comments
 (0)