Skip to content

Commit

Permalink
source shell improve error message when a import inside the source sc…
Browse files Browse the repository at this point in the history
…ript fails

old error message would also show source not found even though the import error is caused in the source not from importing the source
5ila5 committed Oct 25, 2024
1 parent ec2f520 commit 0b5289d
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -217,8 +217,15 @@ def create(
source_module: SourceModule = importlib.import_module(
f"waste_collection_schedule.source.{source_name}"
)
except ImportError:
_LOGGER.error(f"source not found: {source_name}")
except ImportError as e:
if str(e).startswith(
f"No module named 'waste_collection_schedule.source.{source_name}'"
):
_LOGGER.error(f"source not found: {source_name}")
else:
_LOGGER.error(
f"error loading source {source_name}:\n{e} \n{traceback.format_exc()}"
)
return None

# create source

0 comments on commit 0b5289d

Please sign in to comment.