diff --git a/src/components/Images.jsx b/src/components/Images.jsx index 8b14776..3ed487e 100644 --- a/src/components/Images.jsx +++ b/src/components/Images.jsx @@ -55,7 +55,7 @@ function Images({ images, setImages, zhMode, dialogAction, status }) { setImages(modifiedImages) } catch (error) { // 打开对话框 - dialogAction({ type: 'open', title: '收藏失败', content: `Images -> handleStar -> ${error}` }) + dialogAction({ type: 'open', title: '收藏失败', content: `Images -> handleStar -> ${error.name}: ${error.message}` }) } } // 提示词按钮点击事件 diff --git a/src/components/Prompt.jsx b/src/components/Prompt.jsx index caa83cd..96ab44c 100644 --- a/src/components/Prompt.jsx +++ b/src/components/Prompt.jsx @@ -79,7 +79,7 @@ function Prompt({ children, images, setImages, dialogAction, zhMode, status }) { } dialogAction({ type: 'open', title: '生成失败', content: error.message }) } else { - dialogAction({ type: 'open', title: '生成失败', content: `Prompt -> handleSubmit -> ${error}` }) + dialogAction({ type: 'open', title: '生成失败', content: `Prompt -> handleSubmit -> ${error.name}: ${error.message}` }) } } finally { // 启用按钮 @@ -134,7 +134,7 @@ function Prompt({ children, images, setImages, dialogAction, zhMode, status }) { textEN = data.result.translated_text } catch (error) { // 打开对话框 - dialogAction({ type: 'open', title: '翻译失败', content: `${error} (请尝试使用英文模式)` }) + dialogAction({ type: 'open', title: '翻译失败', content: `${error.name}: ${error.message} (请尝试使用英文模式)` }) // 启用按钮 submitRef.current.disabled = false // 设置按钮文本 diff --git a/src/libs/useDialog.jsx b/src/libs/useDialog.jsx index d94a599..eb4f389 100644 --- a/src/libs/useDialog.jsx +++ b/src/libs/useDialog.jsx @@ -23,7 +23,7 @@ function reducer(state, action) { return { title: '', content: '', ele: state.ele } } default: { - throw new Error(`Unsupported action type: ${action.type}`) + throw new TypeError(`Unsupported action type: ${action.type}`) } } }