[OLINGO-792] Improve URI parser error message

This commit is contained in:
Christian Holzer 2015-10-06 16:41:09 +02:00
parent 26c923b6f3
commit d0b225bf18
4 changed files with 13 additions and 5 deletions

View File

@ -662,9 +662,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// do a check for bound functions (which requires a parameter list)
if (ctx.vlNVO.size() == 0) {
throw wrap(new UriParserSemanticException("Expected function parameters for '" + fullBindingTypeName.toString()
+ "'",
UriParserSemanticException.MessageKeys.FUNCTION_PARAMETERS_EXPECTED, fullBindingTypeName.toString()));
throw wrap(new UriParserSemanticException("Unknown type for type cast " + fullFilterName.toString()
+ " not found", UriParserSemanticException.MessageKeys.UNKNOWN_TYPE , fullFilterName.toString()));
}
context.contextReadingFunctionParameters = true;

View File

@ -48,6 +48,8 @@ public class UriParserSemanticException extends UriParserException {
FUNCTION_PARAMETERS_EXPECTED,
/** parameter: resource part */
UNKNOWN_PART,
/** parameter: type */
UNKNOWN_TYPE,
/** parameter: expression */
ONLY_FOR_TYPED_PARTS,
/** parameter: entity type name */

View File

@ -50,6 +50,7 @@ UriParserSemanticException.FUNCTION_PARAMETERS_EXPECTED=Function parameters expe
UriParserSemanticException.UNKNOWN_PART=The part '%1$s' is not defined.
UriParserSemanticException.ONLY_FOR_TYPED_PARTS='%1$s' is only allowed for typed parts.
UriParserSemanticException.UNKNOWN_ENTITY_TYPE=The entity type '%1$s' is not defined.
UriParserSemanticException.UNKNOWN_TYPE=The type of the type cast '%1$s' is not defined.
UriParserSemanticException.ONLY_FOR_COLLECTIONS='%1$s' is only allowed for collections.
UriParserSemanticException.ONLY_FOR_ENTITY_TYPES='%1$s' is only allowed for entity types.
UriParserSemanticException.ONLY_FOR_STRUCTURAL_TYPES='%1$s' is only allowed for structural types.

View File

@ -5442,7 +5442,7 @@ public class TestFullResourcePath {
.isExSemantic(UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE);
testUri.runEx("ESTwoKeyNav/olingo.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav")
.isExSemantic(UriParserSemanticException.MessageKeys.FUNCTION_PARAMETERS_EXPECTED);
.isExSemantic(UriParserSemanticException.MessageKeys.UNKNOWN_TYPE);
// $ref
testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim/$ref")
@ -5563,7 +5563,13 @@ public class TestFullResourcePath {
testUri.runEx("AIRTESAllPrimParam/FICRTString()").isExSemantic(MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS);
testUri.runEx("AIRTESAllPrimParam/AIRTString").isExSemantic(MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS);
}
@Test
public void invalidTypeCast() {
testUri.runEx("ESAllPrim/namespace.Invalid").isExSemantic(MessageKeys.UNKNOWN_TYPE);
testUri.runEx("ESAllPrim(0)/namespace.Invalid").isExSemantic(MessageKeys.UNKNOWN_TYPE);
}
@Test
public void navPropertySameNameAsEntitySet() throws Exception {
testUri.run("ESNavProp(1)/ESNavProp(2)/ESNavProp(3)/ESNavProp")