mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
delegate child errors to parent handler
This commit is contained in:
parent
e1592425b9
commit
f9e35553da
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Database,
|
||||
Gemini,
|
||||
Gemini(super::gemini::Error),
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ pub enum Error {
|
||||
DatabaseRecordCreate(i64, String),
|
||||
DatabaseRecordDelete(i64),
|
||||
DatabaseRecordsRead(String),
|
||||
MemoryIndex,
|
||||
Memory(super::memory::Error),
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
mod error;
|
||||
use error::Error;
|
||||
pub use error::Error;
|
||||
|
||||
use std::{cell::RefCell, collections::HashMap};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
AuthInit,
|
||||
AuthInit(super::auth::Error),
|
||||
DatabaseIndex,
|
||||
DatabaseRecordCreate,
|
||||
MemoryIndex,
|
||||
|
Loading…
x
Reference in New Issue
Block a user