refactor: split database into multiple files, more error handling, cleaner code
This commit is contained in:
parent
4b191a9311
commit
8f67c01efd
17 changed files with 1573 additions and 1630 deletions
36
src/error.rs
Normal file
36
src/error.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use thiserror::Error;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("problem with the database")]
|
||||
SledError {
|
||||
#[from]
|
||||
source: sled::Error,
|
||||
},
|
||||
#[error("tried to parse invalid string")]
|
||||
StringFromBytesError {
|
||||
#[from]
|
||||
source: std::string::FromUtf8Error,
|
||||
},
|
||||
#[error("tried to parse invalid identifier")]
|
||||
SerdeJsonError {
|
||||
#[from]
|
||||
source: serde_json::Error,
|
||||
},
|
||||
#[error("tried to parse invalid identifier")]
|
||||
RumaIdentifierError {
|
||||
#[from]
|
||||
source: ruma_identifiers::Error,
|
||||
},
|
||||
#[error("tried to parse invalid event")]
|
||||
RumaEventError {
|
||||
#[from]
|
||||
source: ruma_events::InvalidEvent,
|
||||
},
|
||||
#[error("bad request")]
|
||||
BadRequest(&'static str),
|
||||
#[error("problem in that database")]
|
||||
BadDatabase(&'static str),
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue