There are a number of places where expressions return -1 where fn:error should be called. Just search the schema for -1.