You really should avoid naming your type plain “Error”
o hai mark
You really should avoid naming your type plain “Error”
I’ve been using obsidian notes for a lot of things. I have a kanban board there that goes buy->bought->in progress->finished->100%
The last step is pretty useless because I never even want to 100% a game. I should remove it. The main use for the board is so when I haven’t played anything in a long time, I can look and go “oh, I had that one going” and pick it up instead of starting some other new game.
I don’t know what app you’re using, but that spoiler tag isn’t part of the spec.
I don’t consider guidelines “hard rules” anyway, just something that’s beneficial to follow where possible. A cat is fine as long as the activity is obvious and the icon is easy to parse and doesn’t stick out. I wouldn’t go “fixing” the GIMP icon either.
Cool! I have kind of lost my judgment from thinking about words so much, but maybe I did hit something good here.
Prefix the name with what it’s for. For example, I’ve previously got a
SoundFontError
from opening soundfont file.“Error” is already used by
std::error::Error
. It might not be imported by the code that imports your error type, but I think it’s better to give it distinct name.The other thing is that you might want to use more than one library. Typical imports at the top of the file might look like this:
use bingbong::{BingBong, BingBongError, SomethingElse}; use bogos::binted::crotchidizer::{Crotchidizer, CrotchidizerError};
If both libraries named their error enums just “Error”, the collision could be worked around, but it’s an unnecessary extra step:
// Not sure how renaming affects compiler hints. use bingbong::{BingBong, Error as BingBongError, SomethingElse}; use bogos::binted::crotchidizer::{Crotchidizer, Error as CrotchidizerError};
or if you want to avoid renaming:
use bingbong::{BingBong, SomethingElse}; use bogos::binted::crotchidizer::{self, Crotchidizer}; /* ... */ match result { Ok(value) => return value, Err(bingbong::Error::MissionFailed) => panic!(), Err(bingbong::Error::UrMom) => todo!(), _ => unreachable!(), } if let Err(crotchidizer::Error::SomethingsWrong) = result2 { // ... }
If the screenshot had followed conventions, the message would say something like this:
could not convert error type `BingBongError` to `MyAppError`