Skip to content
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

feat: handle JSON.parse error #220

Merged
merged 5 commits into from
Feb 3, 2024
Merged

feat: handle JSON.parse error #220

merged 5 commits into from
Feb 3, 2024

Conversation

idranme
Copy link
Contributor

@idranme idranme commented Dec 24, 2023

fix #222

@MaikoTan
Copy link
Member

If you are going to catch that error, you MUST handle it rather than leave it blank in the catch block.

@idranme
Copy link
Contributor Author

idranme commented Dec 25, 2023

If you are going to catch that error, you MUST handle it rather than leave it blank in the catch block.

changed

Copy link
Member

@shigma shigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你是不是应该处理它,而不是单纯 warn 一下?这里的 res.data.info 是不可解析的吗?

@idranme
Copy link
Contributor Author

idranme commented Jan 9, 2024

你是不是应该处理它,而不是单纯 warn 一下?这里的 res.data.info 是不可解析的吗?

更改了

@idranme
Copy link
Contributor Author

idranme commented Jan 9, 2024

你是不是应该处理它,而不是单纯 warn 一下?这里的 res.data.info 是不可解析的吗?

res.data.info 有两种意外的类型,一个是 undefined,另一个是 object

@MaikoTan
Copy link
Member

res.data.info 有两种意外的类型,一个是 undefined,另一个是 object

Then what does JSON.parse() do, suppose that it can only be undefined or object?

@idranme
Copy link
Contributor Author

idranme commented Jan 10, 2024

Then what does JSON.parse() do, suppose that it can only be undefined or object?

throws an error

@idranme idranme changed the title feat: 捕获 JSON 解析失败的情况 feat: handle JSON.parse error Jan 10, 2024
src/index.ts Outdated Show resolved Hide resolved
@shigma shigma merged commit 86d422f into koishijs:main Feb 3, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: "[object Object]" is not valid JSON
3 participants