mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
feat: add context as a property on the LiquidError error
This commit is contained in:
+4
-2
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user