mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 14:00:39 -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
@@ -3,6 +3,7 @@ import { __assign } from 'tslib'
|
||||
import { NormalizedFullOptions, defaultOptions } from '../liquid-options'
|
||||
import { Scope } from './scope'
|
||||
import { isArray, isNil, isString, isFunction, toLiquid } from '../util/underscore'
|
||||
import { InternalUndefinedVariableError } from '../util/error'
|
||||
|
||||
export class Context {
|
||||
private scopes: Scope[] = [{}]
|
||||
@@ -42,7 +43,7 @@ export class Context {
|
||||
return paths.reduce((scope, path) => {
|
||||
scope = readProperty(scope, path)
|
||||
if (isNil(scope) && this.opts.strictVariables) {
|
||||
throw new TypeError(`undefined variable: ${path}`)
|
||||
throw new InternalUndefinedVariableError(path)
|
||||
}
|
||||
return scope
|
||||
}, scope)
|
||||
|
||||
Reference in New Issue
Block a user