minor cleanup with traits

This commit is contained in:
Evan Carroll 2026-01-23 18:27:54 -06:00
parent 73f9c95e37
commit 8a37a7b2da
17 changed files with 81 additions and 71 deletions

View file

@ -6,7 +6,7 @@ use sqlx::PgExecutor;
use uuid::Uuid;
use crate::models::{InventoryItem, LooseProp};
use chattyness_error::AppError;
use chattyness_error::{AppError, OptionExt};
/// Ensure an instance exists for a scene.
///
@ -330,7 +330,7 @@ pub async fn pick_up_loose_prop<'e>(
.bind(user_id)
.fetch_optional(executor)
.await?
.ok_or_else(|| AppError::NotFound("Loose prop not found or has expired".to_string()))?;
.or_not_found("Loose prop (may have expired)")?;
Ok(item)
}
@ -396,7 +396,7 @@ pub async fn update_loose_prop_scale<'e>(
.bind(scale)
.fetch_optional(executor)
.await?
.ok_or_else(|| AppError::NotFound("Loose prop not found or has expired".to_string()))?;
.or_not_found("Loose prop (may have expired)")?;
Ok(prop)
}
@ -490,7 +490,7 @@ pub async fn move_loose_prop<'e>(
.bind(y as f32)
.fetch_optional(executor)
.await?
.ok_or_else(|| AppError::NotFound("Loose prop not found or has expired".to_string()))?;
.or_not_found("Loose prop (may have expired)")?;
Ok(prop)
}
@ -546,7 +546,7 @@ pub async fn lock_loose_prop<'e>(
.bind(locked_by)
.fetch_optional(executor)
.await?
.ok_or_else(|| AppError::NotFound("Loose prop not found or has expired".to_string()))?;
.or_not_found("Loose prop (may have expired)")?;
Ok(prop)
}
@ -600,7 +600,7 @@ pub async fn unlock_loose_prop<'e>(
.bind(loose_prop_id)
.fetch_optional(executor)
.await?
.ok_or_else(|| AppError::NotFound("Loose prop not found or has expired".to_string()))?;
.or_not_found("Loose prop (may have expired)")?;
Ok(prop)
}

View file

@ -4,7 +4,7 @@ use sqlx::PgExecutor;
use uuid::Uuid;
use crate::models::{CreateSceneRequest, Scene, SceneSummary, UpdateSceneRequest};
use chattyness_error::AppError;
use chattyness_error::{AppError, OptionExt};
/// List all scenes for a realm.
pub async fn list_scenes_for_realm<'e>(
@ -374,7 +374,7 @@ pub async fn update_scene<'e>(
let scene = query_builder
.fetch_optional(executor)
.await?
.ok_or_else(|| AppError::NotFound("Scene not found".to_string()))?;
.or_not_found("Scene")?;
Ok(scene)
}

View file

@ -4,7 +4,7 @@ use sqlx::PgExecutor;
use uuid::Uuid;
use crate::models::{CreateSpotRequest, Spot, SpotSummary, UpdateSpotRequest};
use chattyness_error::AppError;
use chattyness_error::{AppError, OptionExt};
/// List all spots for a scene.
pub async fn list_spots_for_scene<'e>(
@ -289,7 +289,7 @@ pub async fn update_spot<'e>(
let spot = query_builder
.fetch_optional(executor)
.await?
.ok_or_else(|| AppError::NotFound("Spot not found".to_string()))?;
.or_not_found("Spot")?;
Ok(spot)
}