Throw an exception if an invalid callback is provided