From b4ba2d1103fd29702a30bf5c9aa056cbbe0a2ba6 Mon Sep 17 00:00:00 2001 From: Himanshi-Mirosoft Date: Tue, 10 Sep 2024 15:39:57 +0530 Subject: [PATCH] fix: exception should come in correct way to user on configuration page and corrected the message (#1291) Co-authored-by: Himanshi Agrawal --- code/backend/batch/utilities/helpers/config/config_helper.py | 2 +- code/backend/pages/04_Configuration.py | 5 ++--- code/tests/utilities/helpers/test_config_helper.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/code/backend/batch/utilities/helpers/config/config_helper.py b/code/backend/batch/utilities/helpers/config/config_helper.py index 677bdf5d4..71772131e 100644 --- a/code/backend/batch/utilities/helpers/config/config_helper.py +++ b/code/backend/batch/utilities/helpers/config/config_helper.py @@ -222,7 +222,7 @@ def validate_config(config: dict): and unsupported_advanced_image_processing_file_type ): raise Exception( - f"Advanced image processing has been enabled for document type {document_type}, but only {ADVANCED_IMAGE_PROCESSING_FILE_TYPES} file types are supported." + f"Advanced image processing has not been enabled for document type {document_type}, as only {ADVANCED_IMAGE_PROCESSING_FILE_TYPES} file types are supported." ) @staticmethod diff --git a/code/backend/pages/04_Configuration.py b/code/backend/pages/04_Configuration.py index c5f682953..1a6bd53a7 100644 --- a/code/backend/pages/04_Configuration.py +++ b/code/backend/pages/04_Configuration.py @@ -1,6 +1,5 @@ import os import sys -import traceback import json import jsonschema import streamlit as st @@ -438,5 +437,5 @@ def validate_documents(): del st.session_state["reset"] del st.session_state["reset_configuration"] -except Exception: - st.error(traceback.format_exc()) +except Exception as e: + st.error(e) diff --git a/code/tests/utilities/helpers/test_config_helper.py b/code/tests/utilities/helpers/test_config_helper.py index 0c2c990dd..0c2f0cb3d 100644 --- a/code/tests/utilities/helpers/test_config_helper.py +++ b/code/tests/utilities/helpers/test_config_helper.py @@ -311,7 +311,7 @@ def test_save_config_as_active_validates_advanced_image_file_types_are_valid( # then assert str(e.value) == ( - "Advanced image processing has been enabled for document type txt, but only ['jpeg', 'jpg', 'png', 'tiff', 'bmp'] file types are supported." + "Advanced image processing has not been enabled for document type txt, as only ['jpeg', 'jpg', 'png', 'tiff', 'bmp'] file types are supported." ) AzureBlobStorageClientMock.assert_not_called()