Skip to content

Commit

Permalink
fix: 错误捕获
Browse files Browse the repository at this point in the history
  • Loading branch information
lixueping committed Nov 6, 2024
1 parent c7d0d03 commit 9d94d0c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
8 changes: 6 additions & 2 deletions packages/guard-core-v4/src/MFA/core/email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ export const VerifyMFAEmail: React.FC<VerifyMFAEmailProps> = ({
message.error(t('login.sendCodeTimeout'))
return false
}
const errorMessage = JSON.parse(e.message)
message.error(errorMessage.message)
try {
const errorMessage = JSON.parse(e.message)
message.error(errorMessage.message)
} catch (_) {
message.error(e)
}
return false
}
}
Expand Down
8 changes: 6 additions & 2 deletions packages/guard-core-v4/src/MFA/core/sms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@ export const VerifyMFASms: React.FC<VerifyMFASmsProps> = ({
message.error(t('login.sendCodeTimeout'))
return false
}
const errorMessage = JSON.parse(e.message)
message.error(errorMessage.message)
try {
const errorMessage = JSON.parse(e.message)
message.error(errorMessage.message)
} catch (_) {
message.error(e)
}
return false
}
}
Expand Down
8 changes: 6 additions & 2 deletions packages/guard-core-v4/src/SendCode/SendCodeByPhone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ export const SendCodeByPhone: React.FC<SendCodeByPhoneProps> = props => {
error
}
}
const { message: msg } = JSON.parse(error.message)
message.error(msg)
try {
const errorMessage = JSON.parse(error.message)
message.error(errorMessage.message)
} catch (_) {
message.error(error)
}
return {
status: false,
error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ export const InputEmailCode: React.FC<Props> = ({
message.error(t('login.sendCodeTimeout'))
return false
}
const errorMessage = JSON.parse(e.message)
message.error(errorMessage.message)
try {
const errorMessage = JSON.parse(e.message)
message.error(errorMessage.message)
} catch (_) {
message.error(e)
}
return false
}
}
Expand Down

0 comments on commit 9d94d0c

Please sign in to comment.