shallowutil: narrow scope of try/except block
This will make this code easier to understand in the future.
Differential Revision: https://phab.mercurial-scm.org/D11007