Clean up exception handling in PackageResourceLoader.

Closes #998.