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:
parent
782deb86d4
commit
4d106b118f
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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",
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user