//! Canonical errors for `server-sync`. use thiserror::Error; #[derive(Debug, Error)] pub enum SyncError { #[error("authentication required: {0}")] AuthenticationRequired(String), #[error("bad request: {0}")] BadRequest(String), #[error("validation error: {0}")] ValidationError(String), #[error("query is too long (max {max})")] QueryTooLong { max: usize }, #[error("copilot is disabled")] CopilotDisabled, #[error("unsupported client version: {client_version} (required {required_version})")] UnsupportedClientVersion { client_version: String, required_version: String, }, #[error("space access denied: {space_id}")] SpaceAccessDenied { space_id: String }, #[error("not in space: {space_id}")] NotInSpace { space_id: String }, #[error("document action {action} denied for {doc_id} in {space_id}")] DocActionDenied { action: String, doc_id: String, space_id: String, }, #[error("access denied: {0}")] AccessDenied(String), #[error("quota exceeded: {0}")] QuotaExceeded(String), #[error("document not found: {doc_id} in {space_id}")] DocNotFound { space_id: String, doc_id: String }, #[error("user not found")] UserNotFound, #[error("space owner not found: {space_id}")] SpaceOwnerNotFound { space_id: String }, #[error("document update blocked: {doc_id} in {space_id}")] DocUpdateBlocked { space_id: String, doc_id: String }, #[error("document update invalid: {0}")] DocUpdateInvalid(String), #[error("document update too large")] DocUpdateTooLarge, #[error("sync permission generation changed for {space_id}")] SyncPermissionGenerationChanged { space_id: String }, #[error("workspace lifecycle not active")] WorkspaceLifecycleNotActive, #[error("Too many concurrent writings")] TooManyConcurrentWritings, #[error("database error: {0}")] Database(String), #[error("internal error: {0}")] Internal(String), } impl From for SyncError { fn from(err: server_db::DbError) -> Self { Self::Database(err.to_string()) } } impl From for SyncError { fn from(err: sqlx::Error) -> Self { Self::Database(err.to_string()) } }