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~
This commit is contained in:
parent
aadea9757b
commit
ab78d1fb7b
12 changed files with 453 additions and 81 deletions
31
atproto/src/error.rs
Normal file
31
atproto/src/error.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue