piston_window icon indicating copy to clipboard operation
piston_window copied to clipboard

Inconsistent error handling

Open mitchmindtree opened this issue 9 years ago • 2 comments

The WindowSettings builder returns a String as its error type, while the Glyphs constructor produces an Error. I think it'd be nice to change the WindowSettings builder error from String to another variant on the Error enum (I quite like being able to see all the possible run-time errors for a library listed as variants of a single enum, and this follows how std::io describes its errors). It might be best to change the error upstream first.

mitchmindtree avatar Dec 19 '15 09:12 mitchmindtree

The reason it uses String is because of https://github.com/PistonDevelopers/piston/blob/master/src/window/src/lib.rs#L39-L43.

There is no finite amount of possible variants, as they are controlled by the window backend. An enum can't be used here.

bvssvni avatar Dec 20 '15 11:12 bvssvni

Ah yes, I see the issue there. I think it'd still be nice to encapsulate this in a variant for piston_window's Error enum so that it's a little clearer where the error is coming from, i.e.

pub enum Error {
    Texture(TextureError),
    Freetype(Error),
    WindowBuilding(String),
}

mitchmindtree avatar Dec 20 '15 11:12 mitchmindtree