fix: update frontend error handling

This commit is contained in:
wancat committed 2023-11-01 23:30:28 +08:00
1 parent af672791a5
commit bcb9f1f803
2 files changed
+11 -2

No files matched your search

+7 -2
View File
@@ -29,6 +29,7 @@ function handleRegister({ username, email, password, success, error }) {
return
}
console.error(err)
error('Something went wrong.')
})
}
@@ -53,8 +54,12 @@ async function check({ username, email, password, error }) {
try {
await checkUsername(username)
} catch (err) {
if (err.response?.status === 400) {
error('Invalid username.')
if (err instanceof ValidationError) {
error(err.message)
return
}
if (err instanceof TooManyRequestsError) {
error('Too many requests. Try again in 2 minutes.')
return
}
console.error(err)