Templating exporter should have clear error reporting (#3945)

* Templating exporter should have clear error reporting

* Using i18n for meesage and removed the unnecessary null check

* Removed usage of bindings

* Adding tests for grel, renamed ParsetTests to TemplatingParserTests

* Regex to test the keys of the template exporter

* Cancel changes to the templating parser

Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
This commit is contained in:
Jathin Sreenivas 2021-11-26 01:49:10 +05:30 committed by GitHub
parent 782deb86d4
commit 4d106b118f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View File

@ -248,7 +248,9 @@ public class Parser {
}
while (_token != null) {
if (_token.type == TokenType.Operator && _token.text.equals(".")) {
if (_token.type == TokenType.Error) {
throw makeException("Unknown function or control named" + _token.text);
} else if (_token.type == TokenType.Operator && _token.text.equals(".")) {
next(false); // swallow .
if (_token == null || _token.type != TokenType.Identifier) {

View File

@ -82,6 +82,9 @@ public class GrelTests extends RefineTest {
"",
"1-1-",
"2**3",
"value{datePart()",
"value}datePart()",
"value.datePart{}",
// "2^3" // TODO: Should this generate an error?
};
for (String test : tests) {

View File

@ -300,6 +300,7 @@
"core-dialogs/for-null-cell-value-to-empty-str-label": "Convert null value to NULL in INSERT",
"core-dialogs/choose-export-destination": "Please choose the destination for project export",
"core-dialogs/export-to-local": "OpenRefine project archive to file",
"core-dialogs/missing-bad-template": "Missing or bad template",
"core-facets/remove-facet": "Remove this facet",
"core-facets/minimize-facet": "Toggle between the minimization and maximization of this facet",
"core-facets/reset": "reset",

View File

@ -139,7 +139,11 @@ TemplatingExporterDialog.prototype._updatePreview = function() {
self._elmts.previewTextarea[0].value = data;
},
"text"
);
).fail(function (jqXhr, textStatus, errorMessage) {
if (jqXhr.status === 500) {
self._elmts.previewTextarea[0].value = $.i18n('core-dialogs/missing-bad-template');
}
});
};
TemplatingExporterDialog.prototype._export = function() {