enshort to common variable name

This commit is contained in:
yggverse 2024-12-14 07:04:23 +02:00
parent dd5fada7c7
commit 293c7d0aa3
15 changed files with 69 additions and 69 deletions

View File

@ -48,7 +48,7 @@ impl Gemini {
.make(None, &widget.form.name.value().unwrap()) .make(None, &widget.form.name.value().unwrap())
{ {
Ok(profile_identity_gemini_id) => profile_identity_gemini_id, Ok(profile_identity_gemini_id) => profile_identity_gemini_id,
Err(reason) => todo!("{}", reason.to_string()), Err(e) => todo!("{}", e.to_string()),
}, },
), ),
Value::ImportPem => Some( Value::ImportPem => Some(
@ -58,7 +58,7 @@ impl Gemini {
.add(&widget.form.file.pem.take().unwrap()) .add(&widget.form.file.pem.take().unwrap())
{ {
Ok(profile_identity_gemini_id) => profile_identity_gemini_id, Ok(profile_identity_gemini_id) => profile_identity_gemini_id,
Err(reason) => todo!("{}", reason.to_string()), Err(e) => todo!("{}", e.to_string()),
}, },
), ),
}; };
@ -67,19 +67,19 @@ impl Gemini {
match option { match option {
// Activate identity for `auth_uri` // Activate identity for `auth_uri`
Some(profile_identity_gemini_id) => { Some(profile_identity_gemini_id) => {
if let Err(reason) = profile if let Err(e) = profile
.identity .identity
.gemini .gemini
.auth .auth
.apply(profile_identity_gemini_id, &auth_url) .apply(profile_identity_gemini_id, &auth_url)
{ {
todo!("{}", reason.to_string()) todo!("{}", e.to_string())
}; };
} }
// Remove all identity auths for `auth_uri` // Remove all identity auths for `auth_uri`
None => { None => {
if let Err(reason) = profile.identity.gemini.auth.remove_scope(&auth_url) { if let Err(e) = profile.identity.gemini.auth.remove_scope(&auth_url) {
todo!("{}", reason.to_string()) todo!("{}", e.to_string())
}; };
} }
} }

View File

@ -75,17 +75,17 @@ impl File {
button.set_css_classes(&["success"]); button.set_css_classes(&["success"]);
button.set_label(filename) button.set_label(filename)
} }
Err(reason) => { Err(e) => {
button.set_css_classes(&["error"]); button.set_css_classes(&["error"]);
button.set_label(reason.message()) button.set_label(e.message())
} }
} }
} }
None => todo!(), None => todo!(),
}, },
Err(reason) => { Err(e) => {
button.set_css_classes(&["warning"]); button.set_css_classes(&["warning"]);
button.set_label(reason.message()) button.set_label(e.message())
} }
} }
button.set_sensitive(true); // unlock button.set_sensitive(true); // unlock

View File

@ -28,11 +28,11 @@ impl Certificate {
data: identity.pem, data: identity.pem,
name: certificate.subject_name().unwrap().replace("CN=", ""), name: certificate.subject_name().unwrap().replace("CN=", ""),
}), }),
Err(reason) => Err(Error::TlsCertificate(reason)), Err(e) => Err(Error::TlsCertificate(e)),
}, },
None => Err(Error::NotFound(profile_identity_gemini_id)), None => Err(Error::NotFound(profile_identity_gemini_id)),
}, },
Err(reason) => Err(Error::Database(reason)), Err(e) => Err(Error::Database(e)),
} }
} }
} }

View File

@ -46,8 +46,8 @@ impl Profile {
env!("CARGO_PKG_VERSION_MINOR") env!("CARGO_PKG_VERSION_MINOR")
)); // @TODO remove after auto-migrate feature implementation )); // @TODO remove after auto-migrate feature implementation
if let Err(reason) = create_dir_all(&config_path) { if let Err(e) = create_dir_all(&config_path) {
panic!("{reason}") panic!("{e}")
} }
// Init database path // Init database path
@ -57,7 +57,7 @@ impl Profile {
// Init database connection // Init database connection
let connection = match Connection::open(database_path.as_path()) { let connection = match Connection::open(database_path.as_path()) {
Ok(connection) => Rc::new(RwLock::new(connection)), Ok(connection) => Rc::new(RwLock::new(connection)),
Err(reason) => panic!("{reason}"), Err(e) => panic!("{e}"),
}; };
// Init profile components // Init profile components
@ -65,24 +65,24 @@ impl Profile {
// Init writable connection // Init writable connection
let mut connection = match connection.write() { let mut connection = match connection.write() {
Ok(connection) => connection, Ok(connection) => connection,
Err(reason) => todo!("{reason}"), Err(e) => todo!("{e}"),
}; };
// Init new transaction // Init new transaction
let transaction = match connection.transaction() { let transaction = match connection.transaction() {
Ok(transaction) => transaction, Ok(transaction) => transaction,
Err(reason) => todo!("{reason}"), Err(e) => todo!("{e}"),
}; };
// Begin migration // Begin migration
match migrate(&transaction) { match migrate(&transaction) {
Ok(_) => { Ok(_) => {
// Confirm changes // Confirm changes
if let Err(reason) = transaction.commit() { if let Err(e) = transaction.commit() {
todo!("{reason}") todo!("{e}")
} }
} }
Err(reason) => todo!("{reason}"), Err(e) => todo!("{e}"),
} }
} // unlock database } // unlock database
@ -94,7 +94,7 @@ impl Profile {
Some(profile) => profile.id, Some(profile) => profile.id,
None => match database.add(true, DateTime::now_local().unwrap(), None) { None => match database.add(true, DateTime::now_local().unwrap(), None) {
Ok(id) => id, Ok(id) => id,
Err(reason) => todo!("{:?}", reason), Err(e) => todo!("{:?}", e),
}, },
}); });
@ -104,7 +104,7 @@ impl Profile {
// Init identity component // Init identity component
let identity = Rc::new(match Identity::new(connection, profile_id) { let identity = Rc::new(match Identity::new(connection, profile_id) {
Ok(result) => result, Ok(result) => result,
Err(reason) => todo!("{:?}", reason.to_string()), Err(e) => todo!("{:?}", e.to_string()),
}); });
// Result // Result
@ -119,8 +119,8 @@ impl Profile {
pub fn migrate(tx: &Transaction) -> Result<(), String> { pub fn migrate(tx: &Transaction) -> Result<(), String> {
// Migrate self components // Migrate self components
if let Err(reason) = database::init(tx) { if let Err(e) = database::init(tx) {
return Err(reason.to_string()); return Err(e.to_string());
} }
// Delegate migration to children components // Delegate migration to children components

View File

@ -28,12 +28,12 @@ impl Bookmark {
match database.records(None) { match database.records(None) {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
if let Err(reason) = memory.add(record.request, record.id) { if let Err(e) = memory.add(record.request, record.id) {
todo!("{}", reason.to_string()) todo!("{}", e.to_string())
} }
} }
} }
Err(reason) => todo!("{}", reason.to_string()), Err(e) => todo!("{}", e.to_string()),
} }
// Return new `Self` // Return new `Self`

View File

@ -52,7 +52,7 @@ impl Database {
// Done // Done
match tx.commit() { match tx.commit() {
Ok(_) => Ok(id), Ok(_) => Ok(id),
Err(reason) => Err(reason), Err(e) => Err(e),
} }
} }
@ -66,9 +66,9 @@ impl Database {
match delete(&tx, id) { match delete(&tx, id) {
Ok(_) => match tx.commit() { Ok(_) => match tx.commit() {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(reason) => Err(reason), Err(e) => Err(e),
}, },
Err(reason) => Err(reason), Err(e) => Err(e),
} }
} }
} }

View File

@ -29,16 +29,16 @@ impl Identity {
Some(identity) => identity.id, Some(identity) => identity.id,
None => match database.add(profile_id, true) { None => match database.add(profile_id, true) {
Ok(id) => id, Ok(id) => id,
Err(reason) => return Err(Error::Database(reason)), Err(e) => return Err(Error::Database(e)),
}, },
}, },
Err(reason) => return Err(Error::Database(reason)), Err(e) => return Err(Error::Database(e)),
}); });
// Init gemini component // Init gemini component
let gemini = Rc::new(match Gemini::new(connection, profile_identity_id) { let gemini = Rc::new(match Gemini::new(connection, profile_identity_id) {
Ok(result) => result, Ok(result) => result,
Err(reason) => return Err(Error::Gemini(reason)), Err(e) => return Err(Error::Gemini(e)),
}); });
// Done // Done
@ -53,8 +53,8 @@ impl Identity {
pub fn migrate(tx: &Transaction) -> Result<(), String> { pub fn migrate(tx: &Transaction) -> Result<(), String> {
// Migrate self components // Migrate self components
if let Err(reason) = database::init(tx) { if let Err(e) = database::init(tx) {
return Err(reason.to_string()); return Err(e.to_string());
} }
// Delegate migration to childs // Delegate migration to childs

View File

@ -59,7 +59,7 @@ impl Database {
// Done // Done
match tx.commit() { match tx.commit() {
Ok(_) => Ok(id), Ok(_) => Ok(id),
Err(reason) => Err(reason), Err(e) => Err(e),
} }
} }
} }

View File

@ -9,11 +9,11 @@ pub enum Error {
impl Display for Error { impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
match self { match self {
Self::Database(reason) => { Self::Database(e) => {
write!(f, "Database error: {reason}") write!(f, "Database error: {e}")
} }
Self::Gemini(reason) => { Self::Gemini(e) => {
write!(f, "Could not init Gemini identity: {reason}") write!(f, "Could not init Gemini identity: {e}")
} }
} }
} }

View File

@ -36,7 +36,7 @@ impl Gemini {
// Init components // Init components
let auth = match Auth::new(connection.clone()) { let auth = match Auth::new(connection.clone()) {
Ok(auth) => Rc::new(auth), Ok(auth) => Rc::new(auth),
Err(reason) => return Err(Error::Auth(reason)), Err(e) => return Err(Error::Auth(e)),
}; };
let database = Rc::new(Database::new(connection, profile_identity_id.clone())); let database = Rc::new(Database::new(connection, profile_identity_id.clone()));
let memory = Rc::new(Memory::new()); let memory = Rc::new(Memory::new());
@ -64,7 +64,7 @@ impl Gemini {
self.index()?; self.index()?;
Ok(profile_identity_gemini_id) Ok(profile_identity_gemini_id)
} }
Err(reason) => Err(Error::Database(reason)), Err(e) => Err(Error::Database(e)),
} }
} }
@ -76,7 +76,7 @@ impl Gemini {
self.index()?; self.index()?;
Ok(()) Ok(())
} }
Err(reason) => Err(Error::Database(reason)), Err(e) => Err(Error::Database(e)),
}, },
Err(e) => Err(Error::Auth(e)), Err(e) => Err(Error::Auth(e)),
} }
@ -97,27 +97,27 @@ impl Gemini {
name, name,
) { ) {
Ok(pem) => self.add(&pem), Ok(pem) => self.add(&pem),
Err(reason) => Err(Error::Certificate(reason)), Err(e) => Err(Error::Certificate(e)),
} }
} }
/// Create new `Memory` index from `Database` for `Self` /// Create new `Memory` index from `Database` for `Self`
pub fn index(&self) -> Result<(), Error> { pub fn index(&self) -> Result<(), Error> {
// Clear previous records // Clear previous records
if let Err(reason) = self.memory.clear() { if let Err(e) = self.memory.clear() {
return Err(Error::Memory(reason)); return Err(Error::Memory(e));
} }
// Build new index // Build new index
match self.database.records() { match self.database.records() {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
if let Err(reason) = self.memory.add(record.id, record.pem) { if let Err(e) = self.memory.add(record.id, record.pem) {
return Err(Error::Memory(reason)); return Err(Error::Memory(e));
} }
} }
} }
Err(reason) => return Err(Error::Database(reason)), Err(e) => return Err(Error::Database(e)),
}; };
Ok(()) Ok(())
@ -135,7 +135,7 @@ impl Gemini {
pem, pem,
}); });
} }
Err(reason) => todo!("{:?}", reason.to_string()), Err(e) => todo!("{:?}", e.to_string()),
} }
} }
None None

View File

@ -49,7 +49,7 @@ impl Auth {
let profile_identity_gemini_auth_id = let profile_identity_gemini_auth_id =
match self.database.add(profile_identity_gemini_id, scope) { match self.database.add(profile_identity_gemini_id, scope) {
Ok(id) => id, Ok(id) => id,
Err(reason) => return Err(Error::Database(reason)), Err(e) => return Err(Error::Database(e)),
}; };
// Reindex // Reindex
@ -64,12 +64,12 @@ impl Auth {
match self.database.records_scope(Some(scope)) { match self.database.records_scope(Some(scope)) {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
if let Err(reason) = self.database.delete(record.id) { if let Err(e) = self.database.delete(record.id) {
return Err(Error::Database(reason)); return Err(Error::Database(e));
} }
} }
} }
Err(reason) => return Err(Error::Database(reason)), Err(e) => return Err(Error::Database(e)),
} }
self.index()?; self.index()?;
Ok(()) Ok(())
@ -80,12 +80,12 @@ impl Auth {
match self.database.records_ref(profile_identity_gemini_id) { match self.database.records_ref(profile_identity_gemini_id) {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
if let Err(reason) = self.database.delete(record.id) { if let Err(e) = self.database.delete(record.id) {
return Err(Error::Database(reason)); return Err(Error::Database(e));
} }
} }
} }
Err(reason) => return Err(Error::Database(reason)), Err(e) => return Err(Error::Database(e)),
} }
self.index()?; self.index()?;
Ok(()) Ok(())
@ -94,23 +94,23 @@ impl Auth {
/// Create new `Memory` index from `Database` for `Self` /// Create new `Memory` index from `Database` for `Self`
pub fn index(&self) -> Result<(), Error> { pub fn index(&self) -> Result<(), Error> {
// Clear previous records // Clear previous records
if let Err(reason) = self.memory.clear() { if let Err(e) = self.memory.clear() {
return Err(Error::Memory(reason)); return Err(Error::Memory(e));
} }
// Build new index // Build new index
match self.database.records_scope(None) { match self.database.records_scope(None) {
Ok(records) => { Ok(records) => {
for record in records { for record in records {
if let Err(reason) = self if let Err(e) = self
.memory .memory
.add(record.scope, record.profile_identity_gemini_id) .add(record.scope, record.profile_identity_gemini_id)
{ {
return Err(Error::Memory(reason)); return Err(Error::Memory(e));
} }
} }
} }
Err(reason) => return Err(Error::Database(reason)), Err(e) => return Err(Error::Database(e)),
} }
Ok(()) Ok(())

View File

@ -37,7 +37,7 @@ impl Database {
// Done // Done
match tx.commit() { match tx.commit() {
Ok(_) => Ok(id), Ok(_) => Ok(id),
Err(reason) => Err(reason), Err(e) => Err(e),
} }
} }
@ -53,7 +53,7 @@ impl Database {
// Done // Done
match tx.commit() { match tx.commit() {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(reason) => Err(reason), Err(e) => Err(e),
} }
} }

View File

@ -9,8 +9,8 @@ pub enum Error {
impl Display for Error { impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> Result { fn fmt(&self, f: &mut Formatter) -> Result {
match self { match self {
Self::Database(reason) => write!(f, "Database error: {reason}"), Self::Database(e) => write!(f, "Database error: {e}"),
Self::Memory(reason) => write!(f, "Memory error: {reason}"), Self::Memory(e) => write!(f, "Memory error: {e}"),
} }
} }
} }

View File

@ -41,7 +41,7 @@ impl Database {
// Done // Done
match tx.commit() { match tx.commit() {
Ok(_) => Ok(id), Ok(_) => Ok(id),
Err(reason) => Err(reason), Err(e) => Err(e),
} }
} }
@ -57,7 +57,7 @@ impl Database {
// Done // Done
match tx.commit() { match tx.commit() {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(reason) => Err(reason), Err(e) => Err(e),
} }
} }

View File

@ -15,7 +15,7 @@ impl Identity {
pub fn to_tls_certificate(&self) -> Result<TlsCertificate, Error> { pub fn to_tls_certificate(&self) -> Result<TlsCertificate, Error> {
match TlsCertificate::from_pem(&self.pem) { match TlsCertificate::from_pem(&self.pem) {
Ok(certificate) => Ok(certificate), Ok(certificate) => Ok(certificate),
Err(reason) => Err(Error::TlsCertificate(reason)), Err(e) => Err(Error::TlsCertificate(e)),
} }
} }
} }