delegate child errors to parent handler

This commit is contained in:
yggverse 2024-11-20 09:27:40 +02:00
parent e1592425b9
commit f9e35553da
7 changed files with 11 additions and 12 deletions

View File

@ -3,7 +3,7 @@ mod error;
mod gemini;
use database::Database;
use error::Error;
pub use error::Error;
use gemini::Gemini;
use sqlite::{Connection, Transaction};
@ -35,7 +35,7 @@ impl Identity {
// Init gemini component
let gemini = Rc::new(match Gemini::new(connection, profile_identity_id) {
Ok(result) => result,
Err(_) => return Err(Error::Gemini),
Err(reason) => return Err(Error::Gemini(reason)),
});
// Done

View File

@ -1,5 +1,5 @@
#[derive(Debug)]
pub enum Error {
Database,
Gemini,
Gemini(super::gemini::Error),
}

View File

@ -6,7 +6,7 @@ mod memory;
use auth::Auth;
use database::Database;
use error::Error;
pub use error::Error;
use memory::Memory;
@ -34,7 +34,7 @@ impl Gemini {
// Init components
let auth = match Auth::new(connection.clone()) {
Ok(auth) => Rc::new(auth),
Err(_) => return Err(Error::AuthInit), // @TODO
Err(reason) => return Err(Error::AuthInit(reason)), // @TODO
};
let database = Rc::new(Database::new(connection, profile_identity_id.clone()));
let memory = Rc::new(Memory::new());

View File

@ -5,7 +5,7 @@ mod error;
mod memory;
use database::Database;
use error::Error;
pub use error::Error;
use memory::Memory;
use sqlite::{Connection, Transaction};
@ -85,12 +85,11 @@ impl Auth {
match self.database.records(None) {
Ok(records) => {
for record in records {
if self
if let Err(reason) = self
.memory
.add(record.url, record.profile_identity_gemini_id)
.is_err()
{
return Err(Error::MemoryIndex);
return Err(Error::Memory(reason));
}
}
}

View File

@ -4,5 +4,5 @@ pub enum Error {
DatabaseRecordCreate(i64, String),
DatabaseRecordDelete(i64),
DatabaseRecordsRead(String),
MemoryIndex,
Memory(super::memory::Error),
}

View File

@ -1,5 +1,5 @@
mod error;
use error::Error;
pub use error::Error;
use std::{cell::RefCell, collections::HashMap};

View File

@ -1,6 +1,6 @@
#[derive(Debug)]
pub enum Error {
AuthInit,
AuthInit(super::auth::Error),
DatabaseIndex,
DatabaseRecordCreate,
MemoryIndex,