-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I needed this to manually test the tracing. So I tidied it up and made it the basis for more formally handling Stele-specific errors.
- Loading branch information
Showing
7 changed files
with
60 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
//! | ||
//! Currently contains only a git microserver. | ||
pub mod errors; | ||
pub mod git; | ||
pub mod tracing; |
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,30 @@ | ||
#![allow( | ||
// derive_more doesn't respect these lints | ||
clippy::pattern_type_mismatch, | ||
clippy::use_self | ||
)] | ||
|
||
//! Stele-specific errors | ||
use actix_web::{error, http::StatusCode, HttpResponse}; | ||
use derive_more::{Display, Error}; | ||
|
||
/// Collection of possible Stele errors | ||
#[derive(Debug, Display, Error)] | ||
pub enum SteleError { | ||
/// Errors generated by the Git server | ||
#[display(fmt = "A Git server occurred")] | ||
GitError, | ||
} | ||
|
||
impl error::ResponseError for SteleError { | ||
fn error_response(&self) -> HttpResponse { | ||
HttpResponse::build(self.status_code()).body(self.to_string()) | ||
} | ||
|
||
fn status_code(&self) -> StatusCode { | ||
match *self { | ||
Self::GitError => StatusCode::INTERNAL_SERVER_ERROR, | ||
} | ||
} | ||
} |
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