handle error codes more often

This commit is contained in:
0/0 2022-12-14 17:21:10 -07:00
parent f810c63a39
commit 4da16a45a3
No known key found for this signature in database
GPG key ID: 3861E636EA1E0E2B
2 changed files with 87 additions and 10 deletions

View file

@ -1,21 +1,39 @@
use std::ffi::{c_int, NulError};
use std::str::Utf8Error;
/// Whisper tends to output errors to stderr, so if an error occurs, check stderr.
#[derive(Debug, Copy, Clone)]
pub enum WhisperError {
/// Failed to create a new context.
InitError,
/// User didn't initialize spectrogram
SpectrogramNotInitialized,
/// Encode was not called.
EncodeNotComplete,
/// Decode was not called.
DecodeNotComplete,
/// Failed to calculate the spectrogram for some reason.
UnableToCalculateSpectrogram,
/// Failed to evaluate model.
UnableToCalculateEvaluation,
/// Failed to run the encoder
FailedToEncode,
/// Failed to run the decoder
FailedToDecode,
/// Invalid number of mel bands.
InvalidMelBands,
/// Invalid thread count
InvalidThreadCount,
/// Invalid UTF-8 detected in a string from Whisper.
InvalidUtf8 {
error_len: Option<usize>,
valid_up_to: usize,
},
NullByteInString {
idx: usize,
},
/// A null byte was detected in a user-provided string.
NullByteInString { idx: usize },
/// Whisper returned a null pointer.
NullPointer,
/// Generic whisper error. Varies depending on the function.
GenericError(c_int),
}