diff --git a/server/data_anndata/anndata_adaptor.py b/server/data_anndata/anndata_adaptor.py index aa20a05f..59d0a494 100644 --- a/server/data_anndata/anndata_adaptor.py +++ b/server/data_anndata/anndata_adaptor.py @@ -173,13 +173,24 @@ class AnndataAdaptor(DataAdaptor): ) except MemoryError: raise DatasetAccessError("Out of memory - file is too large for available memory.") - except Exception: + except Exception as e: import traceback + error_msg = str(e) + + # IMPROVEMENT: Broadly catch ANY version incompatibility + if "No read method registered" in error_msg and "IOSpec" in error_msg: + message = ( + "Error loading file: This H5AD file uses a newer internal format that " + "your version of 'anndata' cannot read.\n" + f"The specific error was: {error_msg}\n" + "Please upgrade anndata in your environment (pip install --upgrade anndata)." + ) + else: + message = ( + "File not found or is inaccessible. File must be an .h5ad object. " + "Please check your input and try again." + ) - message = ( - "File not found or is inaccessible. File must be an .h5ad object. " - "Please check your input and try again." - ) if self.server_config.app__verbose: message += f"\n{traceback.format_exc()}" raise DatasetAccessError(message)