fix: when decrypting file, have better error messages

This commit is contained in:
Davinci 2024-05-09 15:47:46 +02:00
parent 15a3d83610
commit 5d6a3580a6

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')) {
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
}) })