fix: when decrypting file, have better error messages #17

Merged
b merged 11 commits from issue-11 into main 2024-05-14 15:09:01 +00:00
Showing only changes of commit 5d6a3580a6 - Show all commits

View File

@ -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
Review

I would say that a more convenient and reliable approach to handle errors is to have dedicated errors of custom type

I would say that a more convenient and reliable approach to handle errors is to have dedicated errors of custom type
toast.error(`The Key seems to be invalid length or format`)
m marked this conversation as resolved Outdated
Outdated
Review

The message should be The decryption key length or format is invalid.

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
Outdated
Review

The message should be The decryption key is invalid.

The message should be `The decryption key is invalid.`
} else {
toast.error(err.message || 'An error occurred while decrypting file.')
}
setIsLoading(false)
return null
})