Skip to content

Commit

Permalink
优化错误提示
Browse files Browse the repository at this point in the history
  • Loading branch information
LeafYeeXYZ committed Apr 22, 2024
1 parent 3d04033 commit af8eb26
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Images.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}` })
}
}
// 提示词按钮点击事件
Expand Down
4 changes: 2 additions & 2 deletions src/components/Prompt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// 启用按钮
Expand Down Expand Up @@ -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
// 设置按钮文本
Expand Down
2 changes: 1 addition & 1 deletion src/libs/useDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
}
}
Expand Down

0 comments on commit af8eb26

Please sign in to comment.