Nicer log line on ws disconnect
This commit is contained in:
parent
4ca55768c5
commit
ebbececdc9
2 changed files with 31 additions and 27 deletions
|
|
@ -1,13 +1,11 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
use aide::OperationOutput;
|
||||
use axum::{
|
||||
Json,
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use log::{error, info};
|
||||
use schemars::JsonSchema;
|
||||
use log::{debug, error};
|
||||
use serde::Serialize;
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
@ -45,7 +43,7 @@ impl SyncServerError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SerializedError {
|
||||
pub message: String,
|
||||
pub causes: Vec<String>,
|
||||
|
|
@ -96,35 +94,32 @@ impl From<&anyhow::Error> for SerializedError {
|
|||
}
|
||||
}
|
||||
|
||||
impl OperationOutput for SyncServerError {
|
||||
type Inner = Self;
|
||||
}
|
||||
|
||||
pub const fn init_error(error: anyhow::Error) -> SyncServerError {
|
||||
pub fn init_error(error: anyhow::Error) -> SyncServerError {
|
||||
debug!("Initialization error: {error:?}");
|
||||
SyncServerError::InitError(error)
|
||||
}
|
||||
|
||||
pub fn server_error(error: anyhow::Error) -> SyncServerError {
|
||||
error!("Server error: {error:?}");
|
||||
debug!("Server error: {error:?}");
|
||||
SyncServerError::ServerError(error)
|
||||
}
|
||||
|
||||
pub fn client_error(error: anyhow::Error) -> SyncServerError {
|
||||
info!("Client error: {error:?}");
|
||||
debug!("Client error: {error:?}");
|
||||
SyncServerError::ClientError(error)
|
||||
}
|
||||
|
||||
pub fn not_found_error(error: anyhow::Error) -> SyncServerError {
|
||||
info!("Not found: {error:?}");
|
||||
debug!("Not found: {error:?}");
|
||||
SyncServerError::NotFound(error)
|
||||
}
|
||||
|
||||
pub fn unauthenticated_error(error: anyhow::Error) -> SyncServerError {
|
||||
info!("Unauthenticated user: {error:?}");
|
||||
debug!("Unauthenticated user: {error:?}");
|
||||
SyncServerError::Unauthenticated(error)
|
||||
}
|
||||
|
||||
pub fn permission_denied_error(error: anyhow::Error) -> SyncServerError {
|
||||
info!("Permission denied: {error:?}");
|
||||
debug!("Permission denied: {error:?}");
|
||||
SyncServerError::PermissionDeniedError(error)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue