-
Notifications
You must be signed in to change notification settings - Fork 69
refactor(rust): reduce ServiceError (round 1) #2292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| #[derive(Debug, thiserror::Error)] | ||
| pub enum BootloaderHTTPClientError { | ||
| #[error(transparent)] | ||
| HTTP(#[from] BaseHTTPClientError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using transparent for base looks good to me, I would just probably use Base as enum key instead of HTTP as it is confusing with identical enum vealue from BaseHTTPClientError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variant actually wraps BaseHTTPClientError which contains HTTP-related errors (get, post, etc.). The idea is that other errors are more domain-specific.
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
| pub enum StoreError { | ||
| #[error(transparent)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to have it transparent here? I think additional line can help with seeing which part of store failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each error already contain a description (e.g., "Error processing storage settings: {0}").
Prepare to release Agama 15: * #2258 * #2270 * #2277 * #2279 * #2283 * #2284 * #2285 * #2286 * #2287 * #2288 * #2291 * #2292 * #2293 * #2295 * #2297 * #2299 * #2300 * #2301 * #2302 * #2303 * #2305 * #2306 * #2307 * #2308 * #2309 * #2313 * #2314 * #2315 * #2317 * #2318 * #2319 * #2320 * #2321 * #2322 * #2323 * #2324 * #2325 * #2328 * #2329 * #2330 * #2331 * #2335 * #2336 * #2337 * #2338 * #2339 * #2340 * #2342 * #2345 * #2346 * #2348 * #2349 * #2350 * #2351 * #2352 * #2353 * #2354 * #2355 * #2357 * #2358 * #2359 * #2360 * #2361 * #2362 * #2363 * #2364 * #2365 * #2366 * #2368 * #2369 * #2370 * #2371 * #2372 * #2374 * #2377 * #2378 * #2379 * #2380 * #2381 * #2382 * #2384 * #2385 * #2386 * #2388 * #2389 * #2390 * #2391 * #2392 * #2394 * #2397 * #2398 * #2401 * #2403
The Rust part of the project was introduced just as a command-line interface. However, it has turned into a full blown HTTP/API server (with a command-line) and we plan to move more code from Ruby to Rust.
We are learning Rust as we go, so some old decisions might need to be revisited. I have started by trying to simplify the ServiceError enum, which represents an error but includes variants for many different situation (even unrelated ones). We even have an "anyhow" variant!
This first round includes:
ServiceErrorvariants.anyhowin more places of the binary.Once we have put everything into a better place, we can decide to simplify the whole thing if needed. Let's go step by step.
To do
Follow-up
ServiceErrorclean-up.Warning
Do not merge before #2270. We need to fix some conflicts first.