Skip to content

Implement Error::cause() and source() for BacktraceError#113

Open
tormol wants to merge 1 commit intoQuantumBadger:masterfrom
tormol:error_cause
Open

Implement Error::cause() and source() for BacktraceError#113
tormol wants to merge 1 commit intoQuantumBadger:masterfrom
tormol:error_cause

Conversation

@tormol
Copy link

@tormol tormol commented Apr 14, 2024

I didn't notice cause() wasn't coming from the Error trait, until I passed the error to a &dyn Error-taking function and was surprised that cause() was suddenly returning None.

Is there a reason why it's implemented as an inherent method instead of as part of the Error trait?
I don't think a reference to a boxed trait object lets the caller do anything more than they could with a reference to a trait object.

I've ran most of the pre-commit commands, but the --tests part of cargo test and cargo test --no-default-features fails with:

     Running test/main.rs (target/debug/deps/test-e1f5e416b5ec9618)
INFO [test] Running test issue_90_pass_text_between_threads
thread 'main' panicked at test/main.rs:97:10:
called `Result::unwrap()` on an `Err` value: NoAvailablePixelFormat

(On linux with wayland)

@QuantumBadger
Copy link
Owner

Thanks for submitting this. If I remember correctly, those functions in the Error trait were experimental at the time when Speedy2D was released.

In principle this looks fine, it just needs formatting with cargo +nightly fmt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants