mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <wpfleger@block.xyz> Signed-off-by: Will Pfleger <wpfleger@squareup.com> Signed-off-by: Will Pfleger <wpfleger96@gmail.com> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1fgdl5qqnh3k3f2xkqrvt7cujalhm623x4s7fdjdj5yrtp5fzjl9qrjpucw <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub16v54tttfqacx9ycvc3k0ut0npj564ahcuajzy6qjvh57ntmsf4uq4806j2 <d32955ad69077062930cc46cfe2df30ca9aaf6f8e76422681265e9e9af704d78@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Will Pfleger <wpfleger96@gmail.com>
51 lines
1.5 KiB
Rust
51 lines
1.5 KiB
Rust
//! Database error types.
|
||
|
||
use thiserror::Error;
|
||
|
||
/// Errors produced by database operations.
|
||
#[derive(Debug, Error)]
|
||
pub enum DbError {
|
||
/// A SQLx driver-level error.
|
||
#[error("database error: {0}")]
|
||
Sqlx(#[from] sqlx::Error),
|
||
|
||
/// Attempted to store an AUTH event (kind 22242), which is forbidden.
|
||
#[error("AUTH events (kind 22242) must not be stored")]
|
||
AuthEventRejected,
|
||
|
||
/// Attempted to store an ephemeral event (kinds 20000–29999), which is forbidden.
|
||
#[error("ephemeral events (kind {0}) must not be stored")]
|
||
EphemeralEventRejected(u16),
|
||
|
||
/// The requested channel does not exist.
|
||
#[error("channel not found: {0}")]
|
||
ChannelNotFound(uuid::Uuid),
|
||
|
||
/// The requested member is not in the channel.
|
||
#[error("member not found in channel {0}")]
|
||
MemberNotFound(uuid::Uuid),
|
||
|
||
/// A generic not-found error.
|
||
#[error("not found: {0}")]
|
||
NotFound(String),
|
||
|
||
/// The caller lacks permission for the requested operation.
|
||
#[error("access denied: {0}")]
|
||
AccessDenied(String),
|
||
|
||
/// JSON serialization or deserialization failed.
|
||
#[error("serialization error: {0}")]
|
||
Serde(#[from] serde_json::Error),
|
||
|
||
/// A value in the database is malformed or unexpected.
|
||
#[error("invalid data: {0}")]
|
||
InvalidData(String),
|
||
|
||
/// A stored timestamp value could not be interpreted.
|
||
#[error("invalid timestamp: {0}")]
|
||
InvalidTimestamp(i64),
|
||
}
|
||
|
||
/// Convenience alias for `Result<T, DbError>`.
|
||
pub type Result<T> = std::result::Result<T, DbError>;
|