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 encryptionKey
).catch((err) => { ).catch((err) => {
console.log('err in decryption:>> ', err) console.log('err in decryption:>> ', err)
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`)
} else if (err.message.includes('The JWK "alg" member was inconsistent')) {
toast.error(`The Key seems to be invalid.`)
} else {
toast.error(err.message || 'An error occurred while decrypting file.') toast.error(err.message || 'An error occurred while decrypting file.')
}
setIsLoading(false) setIsLoading(false)
return null return null
}) })