There is no need to define a new exception, we can just raise ArgumentError:

    raise ArgumentError, 'Invalid argument for .where.not(), got nil.'