From 9c7cb5752b850d03eff18fd715a4ad1ae0bd2058 Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Sat, 1 May 2021 11:33:19 +0200 Subject: [PATCH] feat: add context as a property on the LiquidError error --- src/util/error.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/error.ts b/src/util/error.ts index b1940dd71..d98cd9b8e 100644 --- a/src/util/error.ts +++ b/src/util/error.ts @@ -4,17 +4,19 @@ import { Template } from '../template/template' export abstract class LiquidError extends Error { private token: Token + private context: string private originalError: Error public constructor (err: Error, token: Token) { super(err.message) this.originalError = err this.token = token + this.context = '' } protected update () { const err = this.originalError - const context = mkContext(this.token) + this.context = mkContext(this.token) this.message = mkMessage(err.message, this.token) - this.stack = this.message + '\n' + context + + this.stack = this.message + '\n' + this.context + '\n' + this.stack + '\nFrom ' + err.stack } }