mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 11:30:13 +08:00
fix: update frontend error handling
This commit is contained in:
1 parent
af672791a5
commit
bcb9f1f803
2 files changed
+11
-2
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user