Ensure the correct exception is set by the listener.