-
-
Notifications
You must be signed in to change notification settings - Fork 143
AIエラーをトーストで表示 #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AIエラーをトーストで表示 #244
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthroughこのプルリクエストでは、 Changes
Possibly related issues
Possibly related PRs
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
src/features/chat/difyChat.ts (2)
86-89: エラーメッセージをより具体的にすることを推奨しますストリーム処理中のエラーに対して、より具体的なエラーメッセージを表示することで、ユーザーがより適切な対応を取れるようになります。
以下のような実装を提案します:
toastStore.getState().addToast({ - message: i18next.t('Errors.AIAPIError'), + message: i18next.t('Errors.AIStreamError', { + details: error.message + }), type: 'error', tag: 'dify-api-error', })
99-104: エラーログの追加を推奨しますエラーをトースト表示して再スローする前に、デバッグ目的でエラーの詳細をログに記録することを推奨します。
以下のような実装を提案します:
+ console.error(`Dify API error:`, { error, errorMessage }); toastStore.getState().addToast({ message: errorMessage, type: 'error', tag: 'dify-api-error', }) throw errorsrc/features/chat/vercelAIChat.ts (2)
138-142: エラー通知の実装が改善されましたストリームでのエラー表示からトースト通知に変更されたことで、ユーザーへのフィードバックが即時に行われるようになりました。
+const VERCEL_API_ERROR_TAG = 'vercel-api-error' as const; toastStore.getState().addToast({ message: errorMessage, type: 'error', - tag: 'vercel-api-error', + tag: VERCEL_API_ERROR_TAG, })タグ文字列を定数として定義することで、将来的な変更や再利用が容易になります。
151-156: エラー処理の重複を改善できますトースト通知の実装は適切ですが、コードの重複が見られます。以下のようにトースト通知のロジックを共通関数として抽出することを推奨します。
+const showVercelApiError = (message: string) => { + toastStore.getState().addToast({ + message, + type: 'error', + tag: VERCEL_API_ERROR_TAG, + }); +}; // 使用例: -toastStore.getState().addToast({ - message: errorMessage, - type: 'error', - tag: 'vercel-api-error', -}); +showVercelApiError(errorMessage);この変更により、コードの再利用性が向上し、将来的な変更も容易になります。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/features/chat/difyChat.ts(3 hunks)src/features/chat/vercelAIChat.ts(3 hunks)
🔇 Additional comments (2)
src/features/chat/difyChat.ts (1)
4-4: トースト通知のインポートが適切に追加されています
エラーハンドリングの改善のため、必要なインポートが正しく追加されています。
src/features/chat/vercelAIChat.ts (1)
7-7: トーストストアのインポートが適切に追加されています
エラー通知の実装に必要なインポートが正しく配置されています。
…sage AIエラーをトーストで表示
関連
Summary by CodeRabbit
新機能
バグ修正