Skip to content

Commit

Permalink
backend: Improve marshal log when load target is missing
Browse files Browse the repository at this point in the history
Produce a friendly message in case Kale tries to load a file/folder at
the beginning of the step and it does not exist.

Signed-off-by: Stefano Fioravanzo <[email protected]>
Reviewed-by: Ilias Katsakioris <[email protected]>
  • Loading branch information
Stefano Fioravanzo authored and elikatsis committed Sep 11, 2020
1 parent beb3b7f commit 28bbd30
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/kale/marshal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

class KaleMarshalException(Exception):
"""Errors that may happen while Kale marshals objects between steps."""
def __init__(self, original_exc, original_traceback, msg=None, obj=None,
obj_name=None, operation=None):
def __init__(self, original_exc=None, original_traceback=None, msg=None,
obj=None, obj_name=None, operation=None):
if msg is None:
# Set some default useful error message
msg = "Kale experienced an error while marshalling %s" % obj
Expand Down Expand Up @@ -115,6 +115,11 @@ def _load(file_name):
% (file_name, str(_kale_load_folder_name)))

_names = _kale_load_file_name + _kale_load_folder_name
if len(_names) == 0:
_msg = KALE_LOAD_ERROR_MSG % (file_name,
"No file or folder was found with"
" the requested name.")
raise KaleMarshalException(msg=_msg)
_kale_load_file_name = _names[0]

return resource_load(os.path.join(KALE_DATA_DIRECTORY,
Expand Down

0 comments on commit 28bbd30

Please sign in to comment.