more explicit code when calling custom function
@@ -617,17 +617,21 @@ def Function(e, ctx):
Custom functions and casts
"""
pair =_CUSTOM_FUNCTIONS.get(e.iri)
- if pair is not None:
+ if pair is None:
+ # no such function is registered
+ raise SPARQLError('Unknown function %r"%e.iri')
func, raw = pair
if raw:
+ # function expects expression and context
return func(e, ctx)
else:
+ # function expects the argument list
try:
return func(*e.expr)
except TypeError as ex:
+ # wrong argument number
raise SPARQLError(*ex.args)
- else:
- raise SPARQLError('Unknown function %r"%e.iri')
+
@custom_function(XSD.string, raw=True)
