Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If you use filter without required argument then php throw Type Error. #126

Closed
PATROMO opened this issue Jun 14, 2019 · 5 comments · Fixed by #128
Closed

If you use filter without required argument then php throw Type Error. #126

PATROMO opened this issue Jun 14, 2019 · 5 comments · Fixed by #128
Labels

Comments

@PATROMO
Copy link

PATROMO commented Jun 14, 2019

Try:

{{"now"|date }} or {{ 4 | plus }}

and you get:

Type error: Too few arguments to function Liquid\StandardFilters::date(), 1 passed and exactly 2 expected 

An LiquidException should be thrown.

@sanmai
Copy link
Collaborator

sanmai commented Jun 14, 2019

That is in fact correct. The date filter requires a format.

https://shopify.github.io/liquid/filters/date/

@PATROMO
Copy link
Author

PATROMO commented Jun 14, 2019

I know, but LiquidException should be thrown and not a PHP Error.

@sanmai
Copy link
Collaborator

sanmai commented Jun 14, 2019

Fair.

@sanmai sanmai added the bug label Jun 14, 2019
@PATROMO
Copy link
Author

PATROMO commented Jun 14, 2019

I will try to create a PR for it. :)

@sanmai
Copy link
Collaborator

sanmai commented Jun 14, 2019

Consider catching TypeError somewhere up the stack, and rethrowing a LiquidException with that TypeError set as a previous exception. That'll be a solution for all other similar cases too.

sanmai added a commit that referenced this issue Jun 17, 2019
…ilterbank

Handle type erros in filterbank

Fixes #126

Fixes #127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants