Skip to content

Commit 0c91b24

Browse files
authored
Make invalid states (more) representable (#10)
Currently, the `AntagonistError` type has some errors that wrap other values, but don't format those values when displayed. This is kind of unfortunate. For example: ``` 2024-10-23T21:01:34.795972Z ERROR omicron_stress: 202: invalid actor state 2024-10-23T21:01:34.796049Z INFO omicron_stress: 218: Halting actors ``` Seeing this in my logs felt kind of painful, because it's like, "okay, what was the invalid state?" and there's no way to find out what it was. It turns out that there's a string that's in there which says what the invalid state was, but it didn't get formatted in the `Display` impl, and now the process has exited, so which invalid state occurred has been permanently lost to the sands of time. After this change, it now looks like this: ``` 2024-10-23T21:25:17.983062Z ERROR omicron_stress: 202: invalid actor state: instance inst1 unexpectedly in state Failed 2024-10-23T21:25:17.983160Z INFO omicron_stress: 218: Halting actors ``` If you compare this with the output from before, you will notice that I have made invalid states representable. In this case, that's actually a good thing.
1 parent 8cf99c4 commit 0c91b24

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/actor/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ pub struct Actor {
4949

5050
#[derive(thiserror::Error, Debug)]
5151
pub enum AntagonistError {
52-
#[error("invalid actor state")]
52+
#[error("invalid actor state: {0}")]
5353
InvalidState(String),
5454

55-
#[error("oxide api error")]
55+
#[error("oxide api error: {0}")]
5656
ApiError(#[from] OxideApiError),
5757

5858
#[error("antagonist {name} disconnected its error channel")]

0 commit comments

Comments
 (0)