Check the return value of `getobj` and `LegacyThrow` the appropriate error if it fails