Throw an exception when a non-object is provided