Files
FunASR/runtime/python
Leonard Li 4999dc7632 Raise real exceptions instead of strings in the runtime Python bindings
`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.
2026-08-22 12:35:50 -04:00
..
2024-12-17 12:40:04 +08:00
2023-11-07 18:34:29 +08:00