[GH-ISSUE #661] Trait Errors #385

Closed
opened 2026-02-27 19:30:20 +03:00 by kerem · 7 comments
Owner

Originally created by @Stateford on GitHub (Mar 2, 2021).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/661

Originally assigned to: @Stateford on GitHub.

Hello, I was trying to run the example from play and I tried to use the shorthand for error checking. I did get this error when trying to use it.

Is there any chance that these errors could inherit the Error trait? I don't mind taking a look at making the change myself.

error[E0277]: the trait bound `SpotifyIdError: std::error::Error` is not satisfied
  --> src\main.rs:36:49
   |
36 |     let track = SpotifyId::from_base62(&args[3])?;
   |                                                 ^ the trait `std::error::Error` is not implemented for `SpotifyIdError`
   |
   = note: required because of the requirements on the impl of `From<SpotifyIdError>` for `Box<dyn std::error::Error>`
   = note: required by `from`

error[E0277]: the trait bound `NoneError: std::error::Error` is not satisfied
  --> src\main.rs:38:44
   |
38 |     let backend = audio_backend::find(None)?;
   |                                            ^ the trait `std::error::Error` is not implemented for `NoneError`
   |
   = note: required because of the requirements on the impl of `From<NoneError>` for `Box<dyn std::error::Error>`
   = note: required by `from`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `foo`

To learn more, run the command again with --verbose.
Originally created by @Stateford on GitHub (Mar 2, 2021). Original GitHub issue: https://github.com/librespot-org/librespot/issues/661 Originally assigned to: @Stateford on GitHub. Hello, I was trying to run the example from play and I tried to use the shorthand for error checking. I did get this error when trying to use it. Is there any chance that these errors could inherit the Error trait? I don't mind taking a look at making the change myself. ``` error[E0277]: the trait bound `SpotifyIdError: std::error::Error` is not satisfied --> src\main.rs:36:49 | 36 | let track = SpotifyId::from_base62(&args[3])?; | ^ the trait `std::error::Error` is not implemented for `SpotifyIdError` | = note: required because of the requirements on the impl of `From<SpotifyIdError>` for `Box<dyn std::error::Error>` = note: required by `from` error[E0277]: the trait bound `NoneError: std::error::Error` is not satisfied --> src\main.rs:38:44 | 38 | let backend = audio_backend::find(None)?; | ^ the trait `std::error::Error` is not implemented for `NoneError` | = note: required because of the requirements on the impl of `From<NoneError>` for `Box<dyn std::error::Error>` = note: required by `from` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. error: could not compile `foo` To learn more, run the command again with --verbose. ```
kerem 2026-02-27 19:30:20 +03:00
Author
Owner

@Johannesd3 commented on GitHub (Mar 2, 2021):

NoneError does not belong to us, it's from the standard library. SpotifyIdError would of course be possible, and there is certainly room for improvement in error handling.

But for now it's simpler if you use Option::ok_or, Option::ok_or_else and Result::map_err, or a separate error handling crate like anyhow.

<!-- gh-comment-id:789191092 --> @Johannesd3 commented on GitHub (Mar 2, 2021): `NoneError` does not belong to us, it's from the standard library. `SpotifyIdError` would of course be possible, and there is certainly room for improvement in error handling. But for now it's simpler if you use `Option::ok_or`, `Option::ok_or_else` and `Result::map_err`, or a separate error handling crate like `anyhow`.
Author
Owner

@Stateford commented on GitHub (Mar 4, 2021):

Yea, so the NoneError makes sense, however it would be a good idea to add it to SpotifyIdError. I'll look at how hard it would be to add.

<!-- gh-comment-id:790887042 --> @Stateford commented on GitHub (Mar 4, 2021): Yea, so the NoneError makes sense, however it would be a good idea to add it to SpotifyIdError. I'll look at how hard it would be to add.
Author
Owner

@roderickvd commented on GitHub (May 25, 2021):

@Stateford I took the liberty to assign this one to you, as you offered to look into it.

<!-- gh-comment-id:848237051 --> @roderickvd commented on GitHub (May 25, 2021): @Stateford I took the liberty to assign this one to you, as you offered to look into it.
Author
Owner

@Stateford commented on GitHub (May 26, 2021):

@roderickvd sure, I don't mind taking a look when I get a chance.

<!-- gh-comment-id:848430831 --> @Stateford commented on GitHub (May 26, 2021): @roderickvd sure, I don't mind taking a look when I get a chance.
Author
Owner

@Johannesd3 commented on GitHub (May 26, 2021):

We switched to thiserror recently, which makes it an easy addition.

<!-- gh-comment-id:848561888 --> @Johannesd3 commented on GitHub (May 26, 2021): We switched to `thiserror` recently, which makes it an easy addition.
Author
Owner

@roderickvd commented on GitHub (Aug 7, 2021):

@Stateford is this still something you would like to pursue?

<!-- gh-comment-id:894702621 --> @roderickvd commented on GitHub (Aug 7, 2021): @Stateford is this still something you would like to pursue?
Author
Owner

@roderickvd commented on GitHub (Jan 12, 2022):

Fixed in new-api @ github.com/librespot-org/librespot@62461be1fc.

<!-- gh-comment-id:1011329575 --> @roderickvd commented on GitHub (Jan 12, 2022): Fixed in `new-api` @ https://github.com/librespot-org/librespot/commit/62461be1fcfcaa93bb52f32cc2f88b7fdcd6ecd7.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#385
No description provided.