Open christophermaier opened 5 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.
This issue has been automatically closed after being stale for 400 days. We still value your input and contribution. Please re-open the issue if desired and leave a comment with details.
Our error.rs module is a bit of a dumping ground. Every error that could possibly be thrown from anywhere in the entire crate is mapped directly back to here. This makes it difficult to discern any kind of order or structure to the errors.
Additionally, there are a large number of
From
implementations that map errors from our dependency crates into trivial wrapper errors in our crate. The fact thatFrom
is used for all?
invocations, coupled with the fact that the wrappers are trivial, means that we lose a lot of potentially valuable context. For example, what doesError::TryRecvError
mean in the context of the Supervisor? Currently, it just means that something, somewhere, threw astd::sync::mpsc::TryRecvError
. Absent some in-depth code reading, you can't easily discover where in the code that error might have come from (let alone where it actually did come from), and there's no indication of what that error actually means, in concrete domain terms, at the point it was thrown.Rather than having a single "dumping ground", I think that we can structure things a bit more hierarchically. That is, we could have a distinct
error.rs
module for each meaningful subsystem of the Supervisor, full of meaningful domain-specific error types (where exactly we draw the lines between those subsystems is an exercise for the reader 😉 ). These types could in turn be collected and consolidated into a single top-level error type for interoperability. Rather than indiscriminately using?
andFrom
implementations to map from errors in dependency crates, we can explicitly map to our domain errors. That is, instead of using?
, we could use.map_err(MySpecificError)
. This stands to make the error types much richer and more meaningful.