From 0da420ce9dbb5c773b804ad1cf5293f593c41dc2 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sun, 28 Aug 2022 21:59:03 -0400 Subject: [PATCH] decomp: better handle decompilation errors (#71) --- src/decomp/decomp-tools.ts | 43 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/decomp/decomp-tools.ts b/src/decomp/decomp-tools.ts index 570fab7..92ffd97 100644 --- a/src/decomp/decomp-tools.ts +++ b/src/decomp/decomp-tools.ts @@ -207,24 +207,33 @@ async function decompFiles(decompConfig: string, fileNames: string[]) { objectNames: fileNames, decompConfig: decompConfig, }); - const { stdout, stderr } = await execFileAsync( - decompilerPath, - [ - `./decompiler/config/${decompConfig}`, - "./iso_data", - "./decompiler_out", - "--config-override", - `{"allowed_objects": [${allowed_objects}]}`, - ], - { - encoding: "utf8", - cwd: projectRoot?.fsPath, - timeout: 20000, - } - ); + try { + const { stdout, stderr } = await execFileAsync( + decompilerPath, + [ + `./decompiler/config/${decompConfig}`, + "./iso_data", + "./decompiler_out", + "--config-override", + `{"allowed_objects": [${allowed_objects}]}`, + ], + { + encoding: "utf8", + cwd: projectRoot?.fsPath, + timeout: 20000, + } + ); + channel.append(stdout.toString()); + channel.append(stderr.toString()); + } catch (error: any) { + vscode.window.showErrorMessage( + "Decompilation Failed, see OpenGOAL Decompiler logs for details" + ); + channel.append( + `DECOMP ERROR:\nSTDOUT:\n${error.stdout}\nSTDERR:\n${error.stderr}` + ); + } updateStatus(DecompStatus.Idle); - channel.append(stdout.toString()); - channel.append(stderr.toString()); } async function decompSpecificFile() {