aboutsummaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/libmpv2/Cargo.toml1
-rw-r--r--crates/libmpv2/src/mpv/errors.rs29
-rw-r--r--crates/libmpv2/src/mpv/raw_error_warning.txt5
3 files changed, 24 insertions, 11 deletions
diff --git a/crates/libmpv2/Cargo.toml b/crates/libmpv2/Cargo.toml
index a8a4ed6..fb2f5bf 100644
--- a/crates/libmpv2/Cargo.toml
+++ b/crates/libmpv2/Cargo.toml
@@ -24,7 +24,6 @@ publish = false
[dependencies]
libmpv2-sys = { path = "libmpv2-sys" }
-thiserror = "2.0.7"
log.workspace = true
[dev-dependencies]
diff --git a/crates/libmpv2/src/mpv/errors.rs b/crates/libmpv2/src/mpv/errors.rs
index a2baee5..4b28fb3 100644
--- a/crates/libmpv2/src/mpv/errors.rs
+++ b/crates/libmpv2/src/mpv/errors.rs
@@ -8,36 +8,45 @@
// You should have received a copy of the License along with this program.
// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
-use std::{ffi::NulError, os::raw as ctype, str::Utf8Error};
-
-use thiserror::Error;
+use std::{ffi::NulError, fmt::Display, os::raw as ctype, str::Utf8Error};
use super::mpv_error;
#[allow(missing_docs)]
pub type Result<T> = ::std::result::Result<T, Error>;
-#[derive(Error, Debug)]
+#[derive(Debug)]
pub enum Error {
- #[error("loading file failed: {error}")]
- Loadfile { error: String },
+ Loadfile {
+ error: String,
+ },
- #[error("version mismatch detected! Linked version ({linked}) is unequal to the loaded version ({loaded})")]
VersionMismatch {
linked: ctype::c_ulong,
loaded: ctype::c_ulong,
},
- #[error("invalid utf8 returned")]
InvalidUtf8,
- #[error("null pointer returned")]
Null,
- #[error("raw error returned: {}", to_string_mpv_error(*(.0)))]
Raw(crate::MpvError),
}
+impl std::error::Error for Error {}
+
+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::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))),
+ }
+ }
+}
+
impl From<NulError> for Error {
fn from(_other: NulError) -> Error {
Error::Null
diff --git a/crates/libmpv2/src/mpv/raw_error_warning.txt b/crates/libmpv2/src/mpv/raw_error_warning.txt
new file mode 100644
index 0000000..277500a
--- /dev/null
+++ b/crates/libmpv2/src/mpv/raw_error_warning.txt
@@ -0,0 +1,5 @@
+Raw mpv error: {}
+
+This error is directly returned from `mpv`.
+This is probably caused by a bug in `yt`, please open an issue about
+this and try to replicate it with the `-vvvv` verbosity setting.