mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
remove duplicated enums
This commit is contained in:
parent
a48f62eb13
commit
58ed923bc7
@ -29,16 +29,16 @@ impl Identity {
|
||||
Some(identity) => identity.id,
|
||||
None => match database.add(profile_id, true) {
|
||||
Ok(id) => id,
|
||||
Err(reason) => return Err(Error::DatabaseAdd(reason)),
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
},
|
||||
},
|
||||
Err(reason) => return Err(Error::DatabaseActive(reason)),
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
});
|
||||
|
||||
// Init gemini component
|
||||
let gemini = Rc::new(match Gemini::new(connection, profile_identity_id) {
|
||||
Ok(result) => result,
|
||||
Err(reason) => return Err(Error::GeminiInit(reason)),
|
||||
Err(reason) => return Err(Error::Gemini(reason)),
|
||||
});
|
||||
|
||||
// Done
|
||||
|
@ -1,6 +1,5 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
DatabaseActive(sqlite::Error),
|
||||
DatabaseAdd(sqlite::Error),
|
||||
GeminiInit(super::gemini::Error),
|
||||
Database(sqlite::Error),
|
||||
Gemini(super::gemini::Error),
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl Gemini {
|
||||
// Init components
|
||||
let auth = match Auth::new(connection.clone()) {
|
||||
Ok(auth) => Rc::new(auth),
|
||||
Err(reason) => return Err(Error::AuthInit(reason)),
|
||||
Err(reason) => return Err(Error::Auth(reason)),
|
||||
};
|
||||
let database = Rc::new(Database::new(connection, profile_identity_id.clone()));
|
||||
let memory = Rc::new(Memory::new());
|
||||
@ -62,7 +62,7 @@ impl Gemini {
|
||||
self.index()?;
|
||||
Ok(profile_identity_gemini_id)
|
||||
}
|
||||
Err(reason) => Err(Error::DatabaseRecordCreate(reason)),
|
||||
Err(reason) => Err(Error::Database(reason)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ impl Gemini {
|
||||
pub fn index(&self) -> Result<(), Error> {
|
||||
// Clear previous records
|
||||
if let Err(reason) = self.memory.clear() {
|
||||
return Err(Error::MemoryClear(reason));
|
||||
return Err(Error::Memory(reason));
|
||||
}
|
||||
|
||||
// Build new index
|
||||
@ -97,11 +97,11 @@ impl Gemini {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
if let Err(reason) = self.memory.add(record.id, record.pem) {
|
||||
return Err(Error::MemoryIndex(reason));
|
||||
return Err(Error::Memory(reason));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(reason) => return Err(Error::DatabaseIndex(reason)),
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
|
@ -49,13 +49,7 @@ impl Auth {
|
||||
let profile_identity_gemini_auth_id =
|
||||
match self.database.add(profile_identity_gemini_id, url) {
|
||||
Ok(id) => id,
|
||||
Err(reason) => {
|
||||
return Err(Error::DatabaseRecordCreate(
|
||||
profile_identity_gemini_id,
|
||||
url.to_string(),
|
||||
reason,
|
||||
))
|
||||
}
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
};
|
||||
|
||||
// Reindex
|
||||
@ -71,11 +65,11 @@ impl Auth {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
if let Err(reason) = self.database.delete(record.id) {
|
||||
return Err(Error::DatabaseRecordDelete(record.id, reason));
|
||||
return Err(Error::Database(reason));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(reason) => return Err(Error::DatabaseRecordsRead(url.to_string(), reason)),
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
}
|
||||
self.index()?;
|
||||
Ok(())
|
||||
@ -85,7 +79,7 @@ impl Auth {
|
||||
pub fn index(&self) -> Result<(), Error> {
|
||||
// Clear previous records
|
||||
if let Err(reason) = self.memory.clear() {
|
||||
return Err(Error::MemoryClear(reason));
|
||||
return Err(Error::Memory(reason));
|
||||
}
|
||||
|
||||
// Build new index
|
||||
@ -96,11 +90,11 @@ impl Auth {
|
||||
.memory
|
||||
.add(record.url, record.profile_identity_gemini_id)
|
||||
{
|
||||
return Err(Error::MemoryIndex(reason));
|
||||
return Err(Error::Memory(reason));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(reason) => return Err(Error::DatabaseIndex(reason)),
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -1,9 +1,5 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
DatabaseIndex(sqlite::Error),
|
||||
DatabaseRecordCreate(i64, String, sqlite::Error),
|
||||
DatabaseRecordDelete(i64, sqlite::Error),
|
||||
DatabaseRecordsRead(String, sqlite::Error),
|
||||
MemoryClear(super::memory::Error),
|
||||
MemoryIndex(super::memory::Error),
|
||||
Database(sqlite::Error),
|
||||
Memory(super::memory::Error),
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
AuthInit(super::auth::Error),
|
||||
DatabaseIndex(sqlite::Error),
|
||||
DatabaseRecordCreate(sqlite::Error),
|
||||
MemoryClear(super::memory::Error),
|
||||
MemoryIndex(super::memory::Error),
|
||||
Certificate(Box<dyn std::error::Error>),
|
||||
Auth(super::auth::Error),
|
||||
Certificate(Box<dyn std::error::Error>), // @TODO
|
||||
Database(sqlite::Error),
|
||||
Memory(super::memory::Error),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user