in reply to Re^2: Testing for a directory handle
in thread Testing for a directory handle

If you do find this general technique useful, I'll just highlight two sections from the warnings pragma documentation which you may want to look at:

Category Hierarchy
The "io" category has seven sub-categories. Depending on what you're actually doing, you may find these useful for more specific tests.
Fatal Warnings
This discusses various caveats with making warnings fatal. It also shows how turn them back to their original non-fatal state.

— Ken