appview/atproto/src/error.rs
Julia Lange ab78d1fb7b
Atproto, types overhaul and error handling
Breaks off from Atrium-rs's types because they are implemented
inconsistently, which makes them harder to use.

This was done with reference to the atproto documentation but
specifically not the atrium-rs codebase so I wouldn't have to think
about licenses.

This adds the types and error module in atproto. It also touches
Cargo.toml for some new dependencies and some shared dependencies. It
required thiserror, so I looped that into the workspace meaning that
this commit touches db.

some things to keep in mind:
- There is no CID parsing
- None of this is tested, nor are there any tests written. We're playing
  fast and loose baby~
2025-06-17 15:14:45 -07:00

31 lines
873 B
Rust

use thiserror::Error as ThisError;
#[non_exhaustive]
#[derive(Debug, ThisError)]
pub enum Error {
#[error("Error while parsing")]
Parse { err: ParseError, object: String },
#[error("Error while formatting")]
Format { err: FormatError, object: String },
}
#[non_exhaustive]
#[derive(Debug, ThisError)]
pub enum FormatError {
#[error("Time Parse Error: {0}")]
Datetime(#[from] time::error::Format),
}
#[non_exhaustive]
#[derive(Debug, ThisError)]
pub enum ParseError {
#[error("Time Parse Error: {0}")]
Datetime(#[from] time::error::Parse),
#[error("Length of parsed object too long, max: {max:?}, got: {got:?}.")]
Length { max: usize, got: usize },
#[error("Currently Did is enforced, cannot use handle, {handle:?}")]
ForceDid { handle: String },
#[error("Incorrectly formatted")]
Format,
}
pub type Result<T> = std::result::Result<T, Error>;