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