refactor: apply 5-pass audit optimizations across mcp-memory codebase
This commit is contained in:
1 parent
924b6d09fa
commit
5bd8b1587a
43 files changed
+1866
-1658
No files matched your search
@@ -13,6 +13,15 @@ pub enum AppError {
|
||||
#[error("Not Found: {0}")]
|
||||
NotFound(String),
|
||||
|
||||
#[error("Entity '{name}' was not found in namespace '{namespace}'")]
|
||||
EntityNotFound { name: String, namespace: String },
|
||||
|
||||
#[error("Invalid relation between '{from}' and '{to}': {reason}")]
|
||||
InvalidRelation { from: String, to: String, reason: String },
|
||||
|
||||
#[error("Database error for key '{key}': {message}")]
|
||||
DatabaseError { key: String, message: String },
|
||||
|
||||
#[error("Forbidden: {0}")]
|
||||
Forbidden(String),
|
||||
|
||||
@@ -39,6 +48,18 @@ impl IntoResponse for AppError {
|
||||
fn into_response(self) -> Response {
|
||||
let (status, error_message) = match &self {
|
||||
AppError::NotFound(msg) => (StatusCode::NOT_FOUND, msg.clone()),
|
||||
AppError::EntityNotFound { name, namespace } => (
|
||||
StatusCode::NOT_FOUND,
|
||||
format!("Entity '{}' was not found in namespace '{}'", name, namespace),
|
||||
),
|
||||
AppError::InvalidRelation { from, to, reason } => (
|
||||
StatusCode::BAD_REQUEST,
|
||||
format!("Invalid relation between '{}' and '{}': {}", from, to, reason),
|
||||
),
|
||||
AppError::DatabaseError { key, message } => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Database error for key '{}': {}", key, message),
|
||||
),
|
||||
AppError::Forbidden(msg) => (StatusCode::FORBIDDEN, msg.clone()),
|
||||
AppError::BadRequest(msg) => (StatusCode::BAD_REQUEST, msg.clone()),
|
||||
AppError::Internal(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg.clone()),
|
||||
|
||||
Reference in new issue
Block a user