diff --git a/speedwagon/exceptions.py b/speedwagon/exceptions.py index f47ddf562..822870455 100644 --- a/speedwagon/exceptions.py +++ b/speedwagon/exceptions.py @@ -20,6 +20,24 @@ class MissingConfiguration(SpeedwagonException): description = "Missing required configuration settings" + def __init__( + self, + message: Optional[str] = None, + workflow: Optional[str] = None, + key: Optional[str] = None + ): + """Create a new exception. + + Args: + message: Message presented by exception + workflow: Name of the workflow that contains the missing value + key: Config key that is missing + """ + super().__init__(message) + self.message = message + self.workflow = workflow + self.key = key + class JobCancelled(Exception): """Job cancelled exception.""" diff --git a/speedwagon/runner_strategies.py b/speedwagon/runner_strategies.py index f6ea0c928..4b4f028a7 100644 --- a/speedwagon/runner_strategies.py +++ b/speedwagon/runner_strategies.py @@ -705,10 +705,29 @@ def run_job_on_thread( total=task_scheduler.total_tasks, ) liaison.callbacks.finished(JobSuccess.SUCCESS) + except speedwagon.exceptions.JobCancelled as job_cancelled: liaison.callbacks.finished(JobSuccess.ABORTED) logging.debug("Job canceled: %s", job_cancelled) + except speedwagon.exceptions.MissingConfiguration as config_error: + liaison.callbacks.finished(JobSuccess.ABORTED) + if config_error.key and config_error.workflow: + logging.debug( + 'Unable to start job with missing configurations: ' + '"%s" from "%s". ' + '\nCheck the Workflow Settings section in ' + 'Speedwagon settings.', + config_error.key, config_error.workflow + ) + else: + logging.debug( + 'Unable to start job with missing configurations. ' + '\nReason: %s' + '\nCheck the Workflow Settings section in ' + 'Speedwagon settings.', + config_error + ) except BaseException as exception_thrown: traceback_info = traceback.format_exc() diff --git a/speedwagon/workflows/workflow_get_marc.py b/speedwagon/workflows/workflow_get_marc.py index 031f2f688..640d81d96 100644 --- a/speedwagon/workflows/workflow_get_marc.py +++ b/speedwagon/workflows/workflow_get_marc.py @@ -89,6 +89,7 @@ class JobArgs(typing.TypedDict): "Identifier type": str, }, ) +GETMARC_SERVER_URL_CONFIG = "Getmarc server url" class GenerateMarcXMLFilesWorkflow(speedwagon.Workflow): @@ -164,7 +165,7 @@ def get_marc_server(self) -> Optional[str]: """Get the server url from the configuration.""" return typing.cast( Optional[str], - self.get_workflow_configuration_value("Getmarc server url"), + self.get_workflow_configuration_value(GETMARC_SERVER_URL_CONFIG), ) def discover_task_metadata( @@ -187,7 +188,10 @@ def discover_task_metadata( _user_args = cast(UserArgs, user_args) server_url = self.get_marc_server() if server_url is None: - raise MissingConfiguration("Getmarc server url is not set") + raise MissingConfiguration( + workflow=self.name, + key=GETMARC_SERVER_URL_CONFIG + ) search_path = _user_args["Input"] jobs: List[Dict[str, Union[str, Collection[str]]]] = [