-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
return error instead of panicking when creating a new server (#4)
* return error instead of panicking Signed-off-by: Dan Bond <danbond@protonmail.com> * bump prometheus-client to 0.18 Signed-off-by: Dan Bond <danbond@protonmail.com> * errors -> error Signed-off-by: Dan Bond <danbond@protonmail.com> * use enum for error Signed-off-by: Dan Bond <danbond@protonmail.com> Signed-off-by: Dan Bond <danbond@protonmail.com>
- Loading branch information
Showing
6 changed files
with
73 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::error::Error; | ||
use std::fmt; | ||
|
||
/// The error type for MetricsServer operations. | ||
#[derive(Debug)] | ||
pub enum ServerError { | ||
/// Represents an error while creating a new server. | ||
Create(String), | ||
} | ||
|
||
impl fmt::Display for ServerError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
ServerError::Create(s) => write!(f, "error creating metrics server: {}", s), | ||
} | ||
} | ||
} | ||
|
||
impl Error for ServerError {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters