mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 05:10:40 -07:00
fix: expose originalError from LiquidError, #742
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ const TRAIT = '__liquidClass__'
|
|||||||
export abstract class LiquidError extends Error {
|
export abstract class LiquidError extends Error {
|
||||||
public token!: Token
|
public token!: Token
|
||||||
public context = ''
|
public context = ''
|
||||||
private originalError?: Error
|
public originalError?: Error
|
||||||
public constructor (err: Error | string, token: Token) {
|
public constructor (err: Error | string, token: Token) {
|
||||||
/**
|
/**
|
||||||
* note: for ES5 targeting, `this` will be replaced by return value of Error(),
|
* note: for ES5 targeting, `this` will be replaced by return value of Error(),
|
||||||
|
|||||||
+10
-1
@@ -1,4 +1,4 @@
|
|||||||
import { TopLevelToken, TagToken, Tokenizer, Context, Liquid, Drop, toValueSync } from '../..'
|
import { TopLevelToken, TagToken, Tokenizer, Context, Liquid, Drop, toValueSync, LiquidError } from '../..'
|
||||||
const LiquidUMD = require('../../dist/liquid.browser.umd.js').Liquid
|
const LiquidUMD = require('../../dist/liquid.browser.umd.js').Liquid
|
||||||
|
|
||||||
describe('Issues', function () {
|
describe('Issues', function () {
|
||||||
@@ -506,4 +506,13 @@ describe('Issues', function () {
|
|||||||
expect(liquid.parseAndRender('{{ 113 | uniq }}')).resolves.toEqual('113')
|
expect(liquid.parseAndRender('{{ 113 | uniq }}')).resolves.toEqual('113')
|
||||||
expect(liquid.parseAndRender("{{ '113' | uniq }}")).resolves.toEqual('113')
|
expect(liquid.parseAndRender("{{ '113' | uniq }}")).resolves.toEqual('113')
|
||||||
})
|
})
|
||||||
|
it('Exposing originalError in LiquidError #742', () => {
|
||||||
|
const engine = new Liquid()
|
||||||
|
engine.registerFilter('error', () => { throw new Error('intended') })
|
||||||
|
try {
|
||||||
|
engine.parseAndRenderSync(`{{ "foo" | error }}`)
|
||||||
|
} catch (err: unknown) {
|
||||||
|
expect(LiquidError.is(err) && err.originalError).toHaveProperty('message', 'intended')
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user