diff options
Diffstat (limited to 'crates/libmpv2/src/mpv/errors.rs')
-rw-r--r-- | crates/libmpv2/src/mpv/errors.rs | 70 |
1 files changed, 56 insertions, 14 deletions
diff --git a/crates/libmpv2/src/mpv/errors.rs b/crates/libmpv2/src/mpv/errors.rs index 4b28fb3..a2d3dd8 100644 --- a/crates/libmpv2/src/mpv/errors.rs +++ b/crates/libmpv2/src/mpv/errors.rs @@ -39,10 +39,17 @@ impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Error::Loadfile { error } => write!(f, "loading file failed: {error}"), - Error::VersionMismatch { linked, loaded } => write!(f, "version mismatch detected! Linked version ({linked}) is unequal to the loaded version ({loaded})"), + Error::VersionMismatch { linked, loaded } => write!( + f, + "version mismatch detected! Linked version ({linked}) is unequal to the loaded version ({loaded})" + ), Error::InvalidUtf8 => f.write_str("invalid utf8 returned"), Error::Null => f.write_str("null pointer returned"), - Error::Raw(raw) => write!(f, include_str!("./raw_error_warning.txt"), to_string_mpv_error(*(raw))), + Error::Raw(raw) => write!( + f, + include_str!("./raw_error_warning.txt"), + to_string_mpv_error(*(raw)) + ), } } } @@ -85,35 +92,70 @@ fn to_string_mpv_error_raw(num: crate::MpvError) -> (&'static str, &'static str) mpv_error::NoMem => ("Memory allocation failed.", ""), - mpv_error::Uninitialized => ("The mpv core wasn't configured and initialized yet", " See the notes in mpv_create()."), + mpv_error::Uninitialized => ( + "The mpv core wasn't configured and initialized yet", + " See the notes in mpv_create().", + ), - mpv_error::InvalidParameter => ("Generic catch-all error if a parameter is set to an invalid or unsupported value.", "This is used if there is no better error code."), + mpv_error::InvalidParameter => ( + "Generic catch-all error if a parameter is set to an invalid or unsupported value.", + "This is used if there is no better error code.", + ), mpv_error::OptionNotFound => ("Trying to set an option that doesn't exist.", ""), - mpv_error::OptionFormat => ("Trying to set an option using an unsupported MPV_FORMAT.", ""), - mpv_error::OptionError => ("Setting the option failed", " Typically this happens if the provided option value could not be parsed."), + mpv_error::OptionFormat => ( + "Trying to set an option using an unsupported MPV_FORMAT.", + "", + ), + mpv_error::OptionError => ( + "Setting the option failed", + " Typically this happens if the provided option value could not be parsed.", + ), mpv_error::PropertyNotFound => ("The accessed property doesn't exist.", ""), - mpv_error::PropertyFormat => ("Trying to set or get a property using an unsupported MPV_FORMAT.", ""), - mpv_error::PropertyUnavailable => ("The property exists, but is not available", "This usually happens when the associated subsystem is not active, e.g. querying audio parameters while audio is disabled."), + mpv_error::PropertyFormat => ( + "Trying to set or get a property using an unsupported MPV_FORMAT.", + "", + ), + mpv_error::PropertyUnavailable => ( + "The property exists, but is not available", + "This usually happens when the associated subsystem is not active, e.g. querying audio parameters while audio is disabled.", + ), mpv_error::PropertyError => ("Error setting or getting a property.", ""), - mpv_error::Command => ("General error when running a command with mpv_command and similar.", ""), + mpv_error::Command => ( + "General error when running a command with mpv_command and similar.", + "", + ), - mpv_error::LoadingFailed => ("Generic error on loading (usually used with mpv_event_end_file.error).", ""), + mpv_error::LoadingFailed => ( + "Generic error on loading (usually used with mpv_event_end_file.error).", + "", + ), mpv_error::AoInitFailed => ("Initializing the audio output failed.", ""), mpv_error::VoInitFailed => ("Initializing the video output failed.", ""), - mpv_error::NothingToPlay => ("There was no audio or video data to play", "This also happens if the file was recognized, but did not contain any audio or video streams, or no streams were selected."), + mpv_error::NothingToPlay => ( + "There was no audio or video data to play", + "This also happens if the file was recognized, but did not contain any audio or video streams, or no streams were selected.", + ), - mpv_error::UnknownFormat => (" * When trying to load the file, the file format could not be determined, or the file was too broken to open it.", ""), + mpv_error::UnknownFormat => ( + " * When trying to load the file, the file format could not be determined, or the file was too broken to open it.", + "", + ), - mpv_error::Generic => ("Generic error for signaling that certain system requirements are not fulfilled.", ""), + mpv_error::Generic => ( + "Generic error for signaling that certain system requirements are not fulfilled.", + "", + ), mpv_error::NotImplemented => ("The API function which was called is a stub only", ""), mpv_error::Unsupported => ("Unspecified error.", ""), - mpv_error::Success => unreachable!("This is not an error. It's just here, to ensure that the 0 case marks an success'"), + mpv_error::Success => unreachable!( + "This is not an error. It's just here, to ensure that the 0 case marks an success'" + ), _ => unreachable!("Mpv seems to have changed it's constants."), } } |