Skip to content

Commit

Permalink
resource: Add another layer of exception catching
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleam committed Oct 18, 2018
1 parent f781014 commit 3512e4b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions niceman/resource/base.py
Expand Up @@ -134,10 +134,13 @@ def factory(config):
except Exception as exc:
# Typically it should be an ImportError, but let's catch and recast
# anything just in case.
msg = exc_str(exc)
known = ResourceManager._discover_types()
if module_name not in known:
msg += ". Known ones are: {}".format(", ".join(known))
try:
msg = exc_str(exc)
known = ResourceManager._discover_types()
if module_name not in known:
msg += ". Known ones are: {}".format(", ".join(known))
except Exception as exc2:
msg += ". Failed to discover resource types: " + exc_str(exc2)
raise ResourceError(
"Failed to import resource: {}".format(msg)
)
Expand Down

0 comments on commit 3512e4b

Please sign in to comment.