Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add load module error message #792

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/masonite/utils/structures.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helpers for multiple data structures"""

import importlib
from importlib.abc import Loader
from dotty_dict import dotty
Expand All @@ -25,10 +26,13 @@ def load(path, object_name=None, default=None, raise_exception=False):
try:
module = importlib.import_module(module_path)
except Exception as e:
error_message = (
f"'{module_path}' not found OR error when importing this module: {str(e)}"
)
print("Warning: " + error_message)

if raise_exception:
raise LoaderNotFound(
f"'{module_path}' not found OR error when importing this module: {str(e)}"
)
raise LoaderNotFound(error_message)
return None

if object_name is None:
Expand Down
Loading