fix: expose originalError from LiquidError, #742

This commit is contained in:
Yang Jun
2024-08-29 11:37:56 +08:00
committed by Jun Yang
parent 62bb20e433
commit 86f6bf0d31
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -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
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')
})
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')
}
})
})