mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 22:10:41 -07:00
add and use error classes for undefined variables
cleans up funky message-matching code in expression.ts for lenient.
This commit is contained in:
committed by
Jun Yang
parent
ca18a579a1
commit
d8f9091a12
@@ -48,6 +48,27 @@ export class RenderError extends LiquidError {
|
||||
}
|
||||
}
|
||||
|
||||
export class UndefinedVariableError extends LiquidError {
|
||||
public constructor (err: Error, token: Token) {
|
||||
super(err, token)
|
||||
this.name = 'UndefinedVariableError'
|
||||
this.message = err.message
|
||||
super.update()
|
||||
}
|
||||
}
|
||||
|
||||
// only used internally; raised where we don't have token information,
|
||||
// so it can't be an UndefinedVariableError.
|
||||
export class InternalUndefinedVariableError extends Error {
|
||||
variableName: string
|
||||
|
||||
public constructor (variableName: string) {
|
||||
super(`undefined variable: ${variableName}`)
|
||||
this.name = 'InternalUndefinedVariableError'
|
||||
this.variableName = variableName
|
||||
}
|
||||
}
|
||||
|
||||
export class AssertionError extends Error {
|
||||
public constructor (message: string) {
|
||||
super(message)
|
||||
|
||||
Reference in New Issue
Block a user