Handle errors
This commit is contained in:
parent
f3b461a62c
commit
3d01775b89
|
@ -120,12 +120,24 @@ export async function decryptFile(
|
|||
const stretched = stretchString(secret, salt)
|
||||
const decipher = crypto.createDecipheriv(ALGO, stretched, iv)
|
||||
|
||||
inputFile.pipe(decipher).pipe(zlib.createGunzip()).pipe(outputFile)
|
||||
const unzip = zlib.createGunzip()
|
||||
|
||||
return new Promise<void>(r => {
|
||||
outputFile.on("finish", () => {
|
||||
inputFile.pipe(decipher).pipe(unzip).pipe(outputFile)
|
||||
|
||||
return new Promise<void>((res, rej) => {
|
||||
inputFile.on("finish", () => {
|
||||
outputFile.close()
|
||||
r()
|
||||
res()
|
||||
})
|
||||
|
||||
decipher.on("error", e => {
|
||||
outputFile.close()
|
||||
rej(e)
|
||||
})
|
||||
|
||||
unzip.on("error", e => {
|
||||
outputFile.close()
|
||||
rej(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import TemplateCard from "components/common/TemplateCard.svelte"
|
||||
import createFromScratchScreen from "builderStore/store/screenTemplates/createFromScratchScreen"
|
||||
import { Roles } from "constants/backend"
|
||||
import { lowercase } from "helpers"
|
||||
|
||||
export let template
|
||||
|
||||
|
@ -190,8 +191,11 @@
|
|||
try {
|
||||
await createNewApp()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
notifications.error("Error creating app")
|
||||
let message = "Error creating app"
|
||||
if (e.message) {
|
||||
message += `: ${lowercase(e.message)}`
|
||||
}
|
||||
notifications.error(message)
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
|
|
@ -134,7 +134,7 @@ async function decryptFiles(path: string, password: string) {
|
|||
}
|
||||
} catch (err: any) {
|
||||
if (err.message === "incorrect header check") {
|
||||
throw new Error("Wrong password")
|
||||
throw new Error("File cannot be imported")
|
||||
}
|
||||
throw err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue