From 1f8b5030f6ff391a1c4a2f36b79946e761277ba6 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Thu, 23 Nov 2023 13:09:28 +1300 Subject: [PATCH] handlebars-templates: Improve "caused by" stack trace from handlebars templates --- .changeset/twenty-plums-draw.md | 5 +++++ packages/handlebars-templates/src/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/twenty-plums-draw.md diff --git a/.changeset/twenty-plums-draw.md b/.changeset/twenty-plums-draw.md new file mode 100644 index 00000000..a0ed66c2 --- /dev/null +++ b/.changeset/twenty-plums-draw.md @@ -0,0 +1,5 @@ +--- +"@openapi-generator-plus/handlebars-templates": patch +--- + +Improve "caused by" stack trace from handlebars templates diff --git a/packages/handlebars-templates/src/index.ts b/packages/handlebars-templates/src/index.ts index 9bad11ae..ccc1c1af 100644 --- a/packages/handlebars-templates/src/index.ts +++ b/packages/handlebars-templates/src/index.ts @@ -90,7 +90,7 @@ export async function emit(templateName: string, outputPath: string, context: Un if (error instanceof Error) { const newError = new Error(`Failed to generate template "${templateName}": ${error.message}`) /* Use the original stack so we can see where we failed */ - newError.stack = `${newError.stack}\nCaused by ${error.stack}` + newError.stack = `${newError.stack}\n Caused by ${error.stack}` throw newError } else { throw new Error(`Failed to generate template "${templateName}": ${error}`)