Added a check for invalid ObjectIds.

If one is provided, a special error is now thrown.