gtk-rs-core icon indicating copy to clipboard operation
gtk-rs-core copied to clipboard

Provide a custom error with attached data

Open A6GibKm opened this issue 2 years ago • 0 comments

When using functions FileExtManual::replace_contents_future the error type does not implement std::Error and using the ? operator requires mapping the error in an awkward way, one possibility is to add a type glib::ErrorWithData with an api that looks like

struct ErrorWithData<T> {
    // ..
}

impl<T> ErrorWithData<T> {
    fn data(&self) -> &T {
        // ..
    }
}

// Or Into<glib::Error>
impl<T> From<ErrorWithData<T>> for glib::Error {
    // ..
}

A6GibKm avatar Feb 16 '23 11:02 A6GibKm