Skip to content

Commit 8396d4e

Browse files
committed
fix: Improve error throwing
1 parent c54e326 commit 8396d4e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/builder.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,21 @@ export class Builder {
5454
const cmd = `${this.buildCmd} -o ${this.outDir}/${this.handler} ${this.entry}`;
5555
const cwd = path.dirname(this.entry);
5656

57-
spawnSync(cmd, {
57+
const goBuild = spawnSync(cmd, {
5858
env: { ...process.env, GOOS: 'linux', ...this.extraEnv },
5959
shell: true,
6060
cwd,
6161
});
62+
63+
if (goBuild.error) {
64+
throw goBuild.error;
65+
}
66+
67+
if (goBuild.status !== 0) {
68+
throw new Error(goBuild.stdout.toString().trim());
69+
}
6270
} catch (err) {
63-
} finally {
71+
throw new Error(`Failed to compile Go function at ${this.entry}: ${err}`);
6472
}
6573
}
6674
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-lambda-golang",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "CDK Construct for AWS Lambda in Golang",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

0 commit comments

Comments
 (0)