Skip to content

Commit 2d014a8

Browse files
authored
chore: add additional stack trace to electronDist error message (#9145)
1 parent 3128991 commit 2d014a8

File tree

7 files changed

+420
-1879
lines changed

7 files changed

+420
-1879
lines changed

.changeset/mean-tigers-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
chore: add additional error stack trace to error message

packages/app-builder-lib/src/electron/ElectronFramework.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, d
197197
const electronDistHook: any = await resolveFunction(packager.appInfo.type, packager.config.electronDist, "electronDist")
198198
resolvedDist = typeof electronDistHook === "function" ? await Promise.resolve(electronDistHook(prepareOptions)) : electronDistHook
199199
} catch (error: any) {
200-
throw new Error("Failed to resolve electronDist: " + error.message)
200+
throw new Error(`Failed to resolve electronDist: ${error.message} ${error.stack}`)
201201
}
202202

203203
if (resolvedDist == null) {
@@ -239,20 +239,20 @@ async function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, d
239239
})
240240
return false
241241
}
242-
}
242+
// if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file
243+
// e.g. we treat it as a custom already-unpacked Electron distribution
244+
log.info({ electronDist: log.filePath(resolvedDist) }, "using custom unpacked Electron distribution")
245+
const source = packager.getElectronSrcDir(resolvedDist)
246+
const destination = packager.getElectronDestinationDir(appOutDir)
247+
log.info({ source, destination }, "copying unpacked Electron")
248+
await emptyDir(appOutDir)
249+
await copyDir(source, destination, {
250+
isUseHardLink: DO_NOT_USE_HARD_LINKS,
251+
})
243252

244-
// if we reach here, it means the provided electronDist is neither a zip file nor a directory with the default zip file
245-
// e.g. we treat it as a custom already-unpacked Electron distribution
246-
log.info({ electronDist: log.filePath(resolvedDist) }, "using custom unpacked Electron distribution")
247-
const source = packager.getElectronSrcDir(resolvedDist)
248-
const destination = packager.getElectronDestinationDir(appOutDir)
249-
log.info({ source, destination }, "copying unpacked Electron")
250-
await emptyDir(appOutDir)
251-
await copyDir(source, destination, {
252-
isUseHardLink: DO_NOT_USE_HARD_LINKS,
253-
})
254-
255-
return false
253+
return false
254+
}
255+
throw new Error("Unable to unpack electron dist")
256256
}
257257

258258
function cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {

0 commit comments

Comments
 (0)