This query returns all call sites of functions in the codebase that return a value of type CustomErrorType , along with the names of the calling function and the called function. First, to exclude all cases in which the returned error was used to update the return value of the calling function, we added the following predicate to the CustomError class: Finally, to model the case in which the returned error was used to update the value of a class member variable, we needed to express the fact that the calling function was a class method and that the return value was used to update the value of a member variable on the same class.