WhisperCt2.Error exception (whisper_ct2 v0.5.0)

Copy Markdown View Source

Structured error returned from WhisperCt2 calls.

reason is one of:

  • :invalid_request - bad arguments (bad path, malformed audio, oversized chunk).
  • :load_error - CTranslate2 could not load the model directory.
  • :inference_error - the Whisper model returned an error during generation.
  • :runtime_error - internal NIF runtime fault (e.g. poisoned mutex).
  • :nif_panic - the Rust side panicked; should never happen in practice.
  • :native_error - fallback for unrecognised native error types.

Summary

Types

reason()

@type reason() ::
  :invalid_request
  | :load_error
  | :inference_error
  | :runtime_error
  | :nif_panic
  | :native_error

t()

@type t() :: %WhisperCt2.Error{
  __exception__: true,
  details: map(),
  message: String.t(),
  reason: reason()
}

Functions

from_native(payload)

@spec from_native(map()) :: t()

new(reason, message, details \\ %{})

@spec new(reason(), String.t(), map()) :: t()