Skip to content

Commit

Permalink
feat: add context as a property on the LiquidError error
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l authored and harttle committed May 1, 2021
1 parent 4e394b9 commit 9c7cb57
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/util/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 9c7cb57

Please sign in to comment.