fix: when decrypting file, have better error messages #17
@ -62,7 +62,15 @@ export const DecryptZip = () => {
|
||||
encryptionKey
|
||||
).catch((err) => {
|
||||
console.log('err in decryption:>> ', err)
|
||||
toast.error(err.message || 'An error occurred while decrypting file.')
|
||||
|
||||
if (err.message.toLowerCase().includes('expected')) {
|
||||
m marked this conversation as resolved
|
||||
toast.error(`The Key seems to be invalid length or format`)
|
||||
m marked this conversation as resolved
Outdated
y
commented
The message should be The message should be `The decryption key length or format is invalid.`
|
||||
} else if (err.message.includes('The JWK "alg" member was inconsistent')) {
|
||||
toast.error(`The Key seems to be invalid.`)
|
||||
m marked this conversation as resolved
Outdated
y
commented
The message should be The message should be `The decryption key is invalid.`
|
||||
} else {
|
||||
toast.error(err.message || 'An error occurred while decrypting file.')
|
||||
}
|
||||
|
||||
setIsLoading(false)
|
||||
return null
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user
I would say that a more convenient and reliable approach to handle errors is to have dedicated errors of custom type