From 660efb3b677130ecfe1248405acb40f16f5c4572 Mon Sep 17 00:00:00 2001 From: SwiftHawk Date: Tue, 16 Apr 2024 13:28:47 +0500 Subject: [PATCH] fix: hanlde error in decryption of zip file --- src/pages/decrypt/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/decrypt/index.tsx b/src/pages/decrypt/index.tsx index af3c2f5..1181ef7 100644 --- a/src/pages/decrypt/index.tsx +++ b/src/pages/decrypt/index.tsx @@ -5,6 +5,7 @@ import { useState } from 'react' import { LoadingSpinner } from '../../components/LoadingSpinner' import { decryptArrayBuffer } from '../../utils' import styles from './style.module.scss' +import { toast } from 'react-toastify' export const DecryptZip = () => { const [selectedFile, setSelectedFile] = useState(null) @@ -25,7 +26,14 @@ export const DecryptZip = () => { const arrayBuffer = await decryptArrayBuffer( encryptedArrayBuffer, encryptionKey - ) + ).catch((err) => { + console.log('err in decryption:>> ', err) + toast.error(err.message || 'An error occurred while decrypting file.') + setIsLoading(false) + return null + }) + + if (!arrayBuffer) return const blob = new Blob([arrayBuffer]) saveAs(blob, 'decrypted.zip')