You really should avoid naming your type plain “Error”
Mark with a Z
o hai mark
- 0 Posts
- 5 Comments
Joined 1 year ago
Cake day: June 1st, 2024
You are not logged in. If you use a Fediverse account that is able to follow users, you can follow this user.
I don’t know what app you’re using, but that spoiler tag isn’t part of the spec.
Mark with a Z@lemmy.kde.socialto Selfhosted@lemmy.world•How I’m building a micro-income system using GPT + PayhipEnglish16·2 months agoMate.
Your site says “no confusion”, “no fluff”, “zero BS”, etc. but the entire page is just incoherent fluff bullshit. I read the page and I have no clue what your product does.
People who make foss apps generally know and care more about programming than secondary things, such as design.
I’ve seen people with weird personal preferences, and some who seemingly perceived design as unnecessary, just getting in the way of “real” work. I think it’s mostly just lack of time and knowledge than an active decision though.
If you have thoughts about my app, I welcome them.
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`