diff --git a/examples/Cargo.toml b/examples/Cargo.toml index ec191e76e..1d59b4f83 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -23,10 +23,10 @@ gstreamer-rtsp-server-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gs gtk = { git = "https://github.com/gtk-rs/gtk", optional = true } gdk = { git = "https://github.com/gtk-rs/gdk", optional = true } gio = { git = "https://github.com/gtk-rs/gio", optional = true } +anyhow = "1.0" +derive_more = "0.99.5" futures = "0.3" byte-slice-cast = "0.3" -failure = "0.1" -failure_derive = "0.1" cairo-rs = { git = "https://github.com/gtk-rs/cairo", features=["use_glib"], optional = true } pango = { git = "https://github.com/gtk-rs/pango", optional = true } pangocairo = { git = "https://github.com/gtk-rs/pangocairo", optional = true } diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index b95c8f350..443f5e155 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -21,27 +21,23 @@ use byte_slice_cast::*; use std::i16; use std::i32; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } fn create_pipeline() -> Result { @@ -162,7 +158,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/appsrc.rs b/examples/src/bin/appsrc.rs index a771c9735..ca51e8bc5 100644 --- a/examples/src/bin/appsrc.rs +++ b/examples/src/bin/appsrc.rs @@ -15,27 +15,23 @@ use gst::prelude::*; extern crate gstreamer_app as gst_app; extern crate gstreamer_video as gst_video; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } const WIDTH: usize = 320; @@ -154,7 +150,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/decodebin.rs b/examples/src/bin/decodebin.rs index 8114e1912..c156b6377 100644 --- a/examples/src/bin/decodebin.rs +++ b/examples/src/bin/decodebin.rs @@ -43,27 +43,23 @@ use std::env; #[cfg(feature = "v1_10")] use std::sync::{Arc, Mutex}; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } #[cfg(feature = "v1_10")] @@ -272,7 +268,7 @@ fn example_main() -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()), }?; @@ -286,7 +282,7 @@ fn example_main() -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/discoverer.rs b/examples/src/bin/discoverer.rs index 87c8860f0..8460c5841 100644 --- a/examples/src/bin/discoverer.rs +++ b/examples/src/bin/discoverer.rs @@ -16,17 +16,17 @@ use crate::pbutils::prelude::*; use crate::pbutils::DiscovererInfo; use crate::pbutils::DiscovererStreamInfo; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; use std::env; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Discoverer error {}", _0)] -struct DiscovererError(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Discoverer error {}", _0)] +struct DiscovererError(#[error(not(source))] &'static str); fn print_tags(info: &DiscovererInfo) { println!("Tags:"); diff --git a/examples/src/bin/encodebin.rs b/examples/src/bin/encodebin.rs index 6bcc572e8..ec62dd193 100644 --- a/examples/src/bin/encodebin.rs +++ b/examples/src/bin/encodebin.rs @@ -29,27 +29,23 @@ use std::env; #[cfg(feature = "v1_10")] use std::sync::{Arc, Mutex}; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } #[cfg(feature = "v1_10")] @@ -302,7 +298,7 @@ fn example_main() -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()), }?; @@ -316,7 +312,7 @@ fn example_main() -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/ges.rs b/examples/src/bin/ges.rs index ebed9496d..11dd68049 100644 --- a/examples/src/bin/ges.rs +++ b/examples/src/bin/ges.rs @@ -47,9 +47,6 @@ use std::env; #[path = "../examples-common.rs"] mod examples_common; -#[allow(unused_imports)] -use failure::Error; - fn main_loop(uri: &str) -> Result<(), glib::BoolError> { ges::init()?; diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs index cb73ab585..261b54812 100644 --- a/examples/src/bin/glupload.rs +++ b/examples/src/bin/glupload.rs @@ -18,27 +18,23 @@ use std::mem; use std::ptr; use std::sync::mpsc; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } #[rustfmt::skip] @@ -587,7 +583,7 @@ impl App { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } @@ -684,7 +680,7 @@ fn main_loop(mut app: App) -> Result, -) -> Result<(), failure::Error> { +) -> Result<(), Error> { // To ensure that the context stays alive longer than the pipeline or any reference // inside GStreamer to the GL context, its display or anything else. See // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/196 diff --git a/examples/src/bin/pango-cairo.rs b/examples/src/bin/pango-cairo.rs index 1a37b3f40..4a3b9ef26 100644 --- a/examples/src/bin/pango-cairo.rs +++ b/examples/src/bin/pango-cairo.rs @@ -20,27 +20,23 @@ use pango::prelude::*; use std::ops; use std::sync::{Arc, Mutex}; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } struct DrawingContext { @@ -247,7 +243,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/player.rs b/examples/src/bin/player.rs index 727fe3c39..322396f74 100644 --- a/examples/src/bin/player.rs +++ b/examples/src/bin/player.rs @@ -13,8 +13,7 @@ extern crate gstreamer_player as gst_player; use std::env; use std::sync::{Arc, Mutex}; -#[allow(unused_imports)] -use failure::Error; +use anyhow::Error; #[allow(unused_imports)] #[path = "../examples-common.rs"] diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index 83553f5f4..759d3e5b6 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -7,36 +7,32 @@ use std::env; #[path = "../examples-common.rs"] mod examples_common; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail(display = "No such pad {} in {}", _0, _1)] -struct NoSuchPad(&'static str, String); +#[derive(Debug, Display, Error)] +#[display(fmt = "No such pad {} in {}", _0, _1)] +struct NoSuchPad(#[error(not(source))] &'static str, String); -#[derive(Debug, Fail)] -#[fail(display = "Unknown payload type {}", _0)] -struct UnknownPT(u32); +#[derive(Debug, Display, Error)] +#[display(fmt = "Unknown payload type {}", _0)] +struct UnknownPT(#[error(not(source))] u32); -#[derive(Debug, Fail)] -#[fail(display = "Usage: {} (play | record) DROP_PROBABILITY", _0)] -struct UsageError(String); +#[derive(Debug, Display, Error)] +#[display(fmt = "Usage: {} (play | record) DROP_PROBABILITY", _0)] +struct UsageError(#[error(not(source))] String); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } fn make_element( @@ -270,7 +266,7 @@ fn example_main() -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index 353c4c41a..5b4cff560 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -7,32 +7,28 @@ mod examples_common; use std::env; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail(display = "No such pad {} in {}", _0, _1)] +#[derive(Debug, Display, Error)] +#[display(fmt = "No such pad {} in {}", _0, _1)] struct NoSuchPad(&'static str, String); -#[derive(Debug, Fail)] -#[fail(display = "Usage: {} URI FEC_PERCENTAGE", _0)] -struct UsageError(String); +#[derive(Debug, Display, Error)] +#[display(fmt = "Usage: {} URI FEC_PERCENTAGE", _0)] +struct UsageError(#[error(not(source))] String); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } fn make_element( @@ -192,7 +188,7 @@ fn example_main() -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/rtsp-server-record.rs b/examples/src/bin/rtsp-server-record.rs index d4b51cbc0..1de9d410a 100644 --- a/examples/src/bin/rtsp-server-record.rs +++ b/examples/src/bin/rtsp-server-record.rs @@ -9,8 +9,6 @@ extern crate gstreamer_rtsp as gst_rtsp; extern crate gstreamer_rtsp_server as gst_rtsp_server; extern crate gstreamer_rtsp_server_sys as gst_rtsp_server_sys; -use failure::Error; -use failure::Fail; use std::env; use std::ptr; @@ -19,16 +17,19 @@ use gst_rtsp::*; use gst_rtsp_server::prelude::*; use gst_rtsp_server::*; +use anyhow::Error; +use derive_more::{Display, Error}; + #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Could not get mount points")] +#[derive(Debug, Display, Error)] +#[display(fmt = "Could not get mount points")] struct NoMountPoints; -#[derive(Debug, Fail)] -#[fail(display = "Usage: {} LAUNCH_LINE", _0)] -struct UsageError(String); +#[derive(Debug, Display, Error)] +#[display(fmt = "Usage: {} LAUNCH_LINE", _0)] +struct UsageError(#[error(not(source))] String); fn main_loop() -> Result<(), Error> { let args: Vec<_> = env::args().collect(); diff --git a/examples/src/bin/rtsp-server-subclass.rs b/examples/src/bin/rtsp-server-subclass.rs index 5ce04259e..199050c74 100644 --- a/examples/src/bin/rtsp-server-subclass.rs +++ b/examples/src/bin/rtsp-server-subclass.rs @@ -19,19 +19,19 @@ use glib::glib_object_subclass; use glib::glib_object_wrapper; use glib::glib_wrapper; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Could not get mount points")] +#[derive(Debug, Display, Error)] +#[display(fmt = "Could not get mount points")] struct NoMountPoints; -#[derive(Debug, Fail)] -#[fail(display = "Usage: {} LAUNCH_LINE", _0)] -struct UsageError(String); +#[derive(Debug, Display, Error)] +#[display(fmt = "Usage: {} LAUNCH_LINE", _0)] +struct UsageError(#[error(not(source))] String); fn main_loop() -> Result<(), Error> { let main_loop = glib::MainLoop::new(None, false); diff --git a/examples/src/bin/rtsp-server.rs b/examples/src/bin/rtsp-server.rs index 6c840bb12..a8c6790a6 100644 --- a/examples/src/bin/rtsp-server.rs +++ b/examples/src/bin/rtsp-server.rs @@ -10,19 +10,19 @@ extern crate gstreamer as gst; extern crate gstreamer_rtsp_server as gst_rtsp_server; use gst_rtsp_server::prelude::*; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Could not get mount points")] +#[derive(Debug, Display, Error)] +#[display(fmt = "Could not get mount points")] struct NoMountPoints; -#[derive(Debug, Fail)] -#[fail(display = "Usage: {} LAUNCH_LINE", _0)] -struct UsageError(String); +#[derive(Debug, Display, Error)] +#[display(fmt = "Usage: {} LAUNCH_LINE", _0)] +struct UsageError(#[error(not(source))] String); fn main_loop() -> Result<(), Error> { let args: Vec<_> = env::args().collect(); diff --git a/examples/src/bin/subclass.rs b/examples/src/bin/subclass.rs index d7259e0c6..5df6c4852 100644 --- a/examples/src/bin/subclass.rs +++ b/examples/src/bin/subclass.rs @@ -17,8 +17,8 @@ use gst::gst_info; use gst::gst_trace; use gst::prelude::*; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; @@ -294,21 +294,17 @@ mod fir_filter { } } -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } fn create_pipeline() -> Result { @@ -384,7 +380,7 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/tagsetter.rs b/examples/src/bin/tagsetter.rs index e48496123..92928260d 100644 --- a/examples/src/bin/tagsetter.rs +++ b/examples/src/bin/tagsetter.rs @@ -21,27 +21,24 @@ extern crate gstreamer as gst; use gst::prelude::*; -use failure::Error; -use failure::Fail; +use anyhow::anyhow; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(String); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] String); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } fn example_main() -> Result<(), Error> { @@ -66,16 +63,16 @@ fn example_main() -> Result<(), Error> { let pipeline = pipeline .downcast::() - .map_err(|_| failure::err_msg("Generated pipeline is no pipeline"))?; + .map_err(|_| anyhow!("Generated pipeline is no pipeline"))?; // Query the pipeline for elements implementing the GstTagsetter interface. // In our case, this will return the flacenc element. let tagsetter = pipeline .get_by_interface(gst::TagSetter::static_type()) - .ok_or_else(|| failure::err_msg("No TagSetter found"))?; + .ok_or_else(|| anyhow!("No TagSetter found"))?; let tagsetter = tagsetter .dynamic_cast::() - .map_err(|_| failure::err_msg("No TagSetter found"))?; + .map_err(|_| anyhow!("No TagSetter found"))?; // Tell the element implementing the GstTagsetter interface how to handle already existing // metadata. @@ -103,7 +100,7 @@ fn example_main() -> Result<(), Error> { .to_string(), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); } diff --git a/examples/src/bin/transmux.rs b/examples/src/bin/transmux.rs index f49755655..687611c09 100644 --- a/examples/src/bin/transmux.rs +++ b/examples/src/bin/transmux.rs @@ -23,27 +23,23 @@ use gst::prelude::*; use std::env; -use failure::Error; -use failure::Fail; +use anyhow::Error; +use derive_more::{Display, Error}; #[path = "../examples-common.rs"] mod examples_common; -#[derive(Debug, Fail)] -#[fail(display = "Missing element {}", _0)] -struct MissingElement(&'static str); +#[derive(Debug, Display, Error)] +#[display(fmt = "Missing element {}", _0)] +struct MissingElement(#[error(not(source))] &'static str); -#[derive(Debug, Fail)] -#[fail( - display = "Received error from {}: {} (debug: {:?})", - src, error, debug -)] +#[derive(Debug, Display, Error)] +#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)] struct ErrorMessage { src: String, error: String, debug: Option, - #[cause] - cause: glib::Error, + source: glib::Error, } fn example_main() -> Result<(), Error> { @@ -170,7 +166,7 @@ fn example_main() -> Result<(), Error> { .unwrap_or_else(|| String::from("None")), error: err.get_error().to_string(), debug: err.get_debug(), - cause: err.get_error(), + source: err.get_error(), } .into()); }