From 2bd97836c2750b6ec5a80030bee4e94985124875 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Thu, 11 Apr 2024 12:27:53 -0400 Subject: [PATCH] provide more process error output (#1620) (#1621) --- pygeoapi/process/manager/base.py | 6 +++--- pygeoapi/process/manager/dummy.py | 8 ++++---- tests/api/test_processes.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pygeoapi/process/manager/base.py b/pygeoapi/process/manager/base.py index d4d8f23..9091cec 100644 --- a/pygeoapi/process/manager/base.py +++ b/pygeoapi/process/manager/base.py @@ -3,7 +3,7 @@ # Authors: Tom Kralidis # Ricardo Garcia Silva # -# Copyright (c) 2022 Tom Kralidis +# Copyright (c) 2024 Tom Kralidis # (c) 2023 Ricardo Garcia Silva # # Permission is hereby granted, free of charge, to any person @@ -303,9 +303,9 @@ class BaseManager: outputs = { 'type': code, 'code': code, - 'description': 'Error updating job' + 'description': f'Error executing process: {err}' } - LOGGER.error(err) + LOGGER.exception(err) job_metadata = { 'job_end_datetime': datetime.utcnow().strftime( DATETIME_FORMAT), diff --git a/pygeoapi/process/manager/dummy.py b/pygeoapi/process/manager/dummy.py index eb35eee..43749c0 100644 --- a/pygeoapi/process/manager/dummy.py +++ b/pygeoapi/process/manager/dummy.py @@ -2,7 +2,7 @@ # # Authors: Tom Kralidis # -# Copyright (c) 2022 Tom Kralidis +# Copyright (c) 2024 Tom Kralidis # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -102,13 +102,13 @@ class DummyManager(BaseManager): jfmt, outputs = processor.execute(data_dict) current_status = JobStatus.successful self._send_success_notification(subscriber, outputs) - except Exception: + except Exception as err: outputs = { 'code': 'InvalidParameterValue', - 'description': 'Error updating job' + 'description': f'Error executing process: {err}' } current_status = JobStatus.failed - LOGGER.exception('Process failed') + LOGGER.exception(err) self._send_failed_notification(subscriber) job_id = str(uuid.uuid1()) return job_id, jfmt, outputs, current_status, response_headers diff --git a/tests/api/test_processes.py b/tests/api/test_processes.py index b83305f..a339728 100644 --- a/tests/api/test_processes.py +++ b/tests/api/test_processes.py @@ -284,7 +284,7 @@ def test_execute_process(config, api_): assert code == HTTPStatus.BAD_REQUEST assert 'Location' in rsp_headers assert data['code'] == 'InvalidParameterValue' - assert data['description'] == 'Error updating job' + assert data['description'].startswith('Error executing process: ') cleanup_jobs.add(tuple(['hello-world', rsp_headers['Location'].split('/')[-1]])) @@ -296,7 +296,7 @@ def test_execute_process(config, api_): assert code == HTTPStatus.BAD_REQUEST assert 'Location' in rsp_headers assert data['code'] == 'InvalidParameterValue' - assert data['description'] == 'Error updating job' + assert data['description'].startswith('Error executing process: ') cleanup_jobs.add(tuple(['hello-world', rsp_headers['Location'].split('/')[-1]]))