improvement: log bad database errors automatically
This commit is contained in:
parent
2368a90584
commit
56d4742201
13 changed files with 278 additions and 208 deletions
|
@ -1,5 +1,6 @@
|
|||
use crate::RumaResponse;
|
||||
use http::StatusCode;
|
||||
use log::error;
|
||||
use rocket::{
|
||||
response::{self, Responder},
|
||||
Request,
|
||||
|
@ -27,6 +28,7 @@ pub enum Error {
|
|||
#[error("{0}")]
|
||||
BadConfig(&'static str),
|
||||
#[error("{0}")]
|
||||
/// Don't create this directly. Use Error::bad_database instead.
|
||||
BadDatabase(&'static str),
|
||||
#[error("uiaa")]
|
||||
Uiaa(UiaaInfo),
|
||||
|
@ -37,6 +39,13 @@ pub enum Error {
|
|||
Conflict(&'static str), // This is only needed for when a room alias already exists
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn bad_database(message: &'static str) -> Self {
|
||||
error!("BadDatabase: {}", message);
|
||||
Self::BadDatabase(message)
|
||||
}
|
||||
}
|
||||
|
||||
#[rocket::async_trait]
|
||||
impl<'r> Responder<'r> for Error {
|
||||
async fn respond_to(self, r: &'r Request<'_>) -> response::Result<'r> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue