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

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ impl Database {
// Done
match tx.commit() {
Ok(_) => Ok(id),
Err(reason) => Err(reason),
Err(e) => Err(e),
}
}
@ -66,9 +66,9 @@ impl Database {
match delete(&tx, id) {
Ok(_) => match tx.commit() {
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,
None => match database.add(profile_id, true) {
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
let gemini = Rc::new(match Gemini::new(connection, profile_identity_id) {
Ok(result) => result,
Err(reason) => return Err(Error::Gemini(reason)),
Err(e) => return Err(Error::Gemini(e)),
});
// Done
@ -53,8 +53,8 @@ impl Identity {
pub fn migrate(tx: &Transaction) -> Result<(), String> {
// Migrate self components
if let Err(reason) = database::init(tx) {
return Err(reason.to_string());
if let Err(e) = database::init(tx) {
return Err(e.to_string());
}
// Delegate migration to childs

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ impl Database {
// Done
match tx.commit() {
Ok(_) => Ok(id),
Err(reason) => Err(reason),
Err(e) => Err(e),
}
}
@ -57,7 +57,7 @@ impl Database {
// Done
match tx.commit() {
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> {
match TlsCertificate::from_pem(&self.pem) {
Ok(certificate) => Ok(certificate),
Err(reason) => Err(Error::TlsCertificate(reason)),
Err(e) => Err(Error::TlsCertificate(e)),
}
}
}