Commit 66f0899a authored by myhloli's avatar myhloli
Browse files

fix(model): handle import errors and improve exception logging

- Add ImportError handling to silence known import-related exceptions
- Improve generic exception handling to log error messages- Maintain existing specific exception handlers for license-related issues
parent d5f6fbc6
...@@ -16,7 +16,9 @@ try: ...@@ -16,7 +16,9 @@ try:
license_key = load_license() license_key = load_license()
logger.info(f'Using Ascend Plugin Success, License expired at {license_key["payload"]["date"]["end_date"]}') logger.info(f'Using Ascend Plugin Success, License expired at {license_key["payload"]["date"]["end_date"]}')
except Exception as e: except Exception as e:
if isinstance(e, LicenseFormatError): if isinstance(e, ImportError):
pass
elif isinstance(e, LicenseFormatError):
logger.error("Ascend Plugin: Invalid license format. Please check the license file.") logger.error("Ascend Plugin: Invalid license format. Please check the license file.")
elif isinstance(e, LicenseSignatureError): elif isinstance(e, LicenseSignatureError):
logger.error("Ascend Plugin: Invalid signature. The license may be tampered with.") logger.error("Ascend Plugin: Invalid signature. The license may be tampered with.")
...@@ -25,7 +27,7 @@ except Exception as e: ...@@ -25,7 +27,7 @@ except Exception as e:
elif isinstance(e, FileNotFoundError): elif isinstance(e, FileNotFoundError):
logger.error("Ascend Plugin: Not found License file.") logger.error("Ascend Plugin: Not found License file.")
else: else:
pass logger.error(f"Ascend Plugin: {e}")
from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_273_mod import ModifiedPaddleOCR from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_273_mod import ModifiedPaddleOCR
# from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_291_mod import ModifiedPaddleOCR # from magic_pdf.model.sub_modules.ocr.paddleocr.ppocr_291_mod import ModifiedPaddleOCR
from magic_pdf.model.sub_modules.table.rapidtable.rapid_table import RapidTableModel from magic_pdf.model.sub_modules.table.rapidtable.rapid_table import RapidTableModel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment