Open
Description
String
does not implement std::error::Error
, making interoperability with error-handling crates such as failure
or anyhow
much more difficult.
SDL2 already has an Error
enum, with variant SdlError(String)
, we just need to use it.
Right now, to use anyhow
's Context
extension, for example, one needs to do the following:
use anyhow::{Context, Result}
fn main() -> Result<()> {
let sdl = sdl2::init().map_err(sdl2::Error::SdlError).context("Failed to initialize SDL lbirary.")?;
}
unrelated, but why is render::SdlError
a seperate newtype around a String
, independent from the above mentioned Error
enum (which has an un-newtyped variant of the same name)? It is only used by TargetRenderError
.