mirror of
https://github.com/modelscope/FunASR.git
synced 2026-10-12 02:19:18 +00:00
`raise "some message"` is invalid in Python 3 — a str is not an exception — so
the interpreter discards the message and raises
TypeError: exceptions must derive from BaseException
instead. Paired with a bare `except:`, the original cause is lost too, and the
user is told to install something they may already have.
Concretely: funasr was installed, but importing it failed on a missing
torchaudio. The message said 'please install funasr', the traceback said
TypeError, and the actual ModuleNotFoundError was nowhere to be seen.
This converts all 30 occurrences under runtime/python to real exceptions:
- guarded imports -> except ImportError as e: raise ImportError(...) from e
- everything else -> except Exception as e: raise RuntimeError(...) from e
`from e` keeps the original traceback, so a missing transitive dependency stays
visible. Narrowing the bare `except:` also stops unrelated failures from being
reported as a missing package — the model_dir branch in particular fired for any
failure, so a mistyped path also surfaced as TypeError.
Messages are unchanged. No behaviour changes beyond the exception type.