Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
d2661e04
Unverified
Commit
d2661e04
authored
3 years ago
by
Ariya Hidayat
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Custom expression parser: error messages are i18n-ready (#19438)
parent
d52f328a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/lib/expressions/recursive-parser.js
+8
-6
8 additions, 6 deletions
frontend/src/metabase/lib/expressions/recursive-parser.js
with
8 additions
and
6 deletions
frontend/src/metabase/lib/expressions/recursive-parser.js
+
8
−
6
View file @
d2661e04
import
{
t
okenize
,
TOKEN
,
OPERATOR
as
OP
}
from
"
./tokenizer
"
;
import
{
t
}
from
"
ttag
"
;
import
{
tokenize
,
TOKEN
,
OPERATOR
as
OP
}
from
"
./tokenizer
"
;
import
{
getMBQLName
,
MBQL_CLAUSES
}
from
"
./index
"
;
const
COMPARISON_OPS
=
[
...
...
@@ -21,12 +22,12 @@ function recursiveParse(source) {
const
expectOp
=
nextOp
=>
{
const
token
=
next
();
if
(
!
token
)
{
throw
new
Error
(
`Unexpected end of input, expecting
${
nextOp
}
`
);
throw
new
Error
(
t
`Unexpected end of input, expecting
${
nextOp
}
`
);
}
const
{
type
,
op
,
start
,
end
}
=
token
;
if
(
type
!==
TOKEN
.
Operator
||
op
!==
nextOp
)
{
const
text
=
source
.
substring
(
start
,
end
);
throw
new
Error
(
`Expecting
${
nextOp
}
but got
${
text
}
instead`
);
throw
new
Error
(
t
`Expecting
${
nextOp
}
but got
${
text
}
instead`
);
}
};
...
...
@@ -43,7 +44,7 @@ function recursiveParse(source) {
const
terminated
=
matchOps
([
OP
.
CloseParenthesis
]);
expectOp
(
OP
.
CloseParenthesis
);
if
(
!
terminated
)
{
throw
new
Error
(
"
Expecting a closing parenthesis
"
);
throw
new
Error
(
t
`
Expecting a closing parenthesis
`
);
}
return
expr
;
};
...
...
@@ -82,11 +83,12 @@ function recursiveParse(source) {
}
const
token
=
next
();
if
(
!
token
)
{
throw
new
Error
(
"
Unexpected end of input
"
);
throw
new
Error
(
t
`
Unexpected end of input
`
);
}
const
{
type
,
start
,
end
}
=
token
;
if
(
type
===
TOKEN
.
Operator
)
{
throw
new
Error
(
"
Unexpected operator
"
);
const
text
=
source
.
substring
(
start
,
end
);
throw
new
Error
(
t
`Unexpected operator
${
text
}
`
);
}
const
text
=
source
.
substring
(
start
,
end
);
if
(
type
===
TOKEN
.
Identifier
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment