Replace ok_or with ok_or_else (#4573)
This commit is contained in:
parent
bc6ad3a983
commit
f795434345
1 changed files with 38 additions and 35 deletions
|
@ -790,7 +790,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::NdNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::NdNotFound {
|
||||||
value: id.to_string(),
|
value: id.to_string(),
|
||||||
})?;
|
})?;
|
||||||
let val: Node = val.into();
|
let val: Node = val.into();
|
||||||
|
@ -810,7 +810,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::UserRootNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::UserRootNotFound {
|
||||||
value: us.to_owned(),
|
value: us.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineUserStatement = val.into();
|
let val: DefineUserStatement = val.into();
|
||||||
|
@ -830,7 +830,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::AccessRootNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::AccessRootNotFound {
|
||||||
ac: ra.to_owned(),
|
ac: ra.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineAccessStatement = val.into();
|
let val: DefineAccessStatement = val.into();
|
||||||
|
@ -854,7 +854,8 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::AccessGrantRootNotFound {
|
let val =
|
||||||
|
self.get(key, None).await?.ok_or_else(|| Error::AccessGrantRootNotFound {
|
||||||
ac: ac.to_owned(),
|
ac: ac.to_owned(),
|
||||||
gr: gr.to_owned(),
|
gr: gr.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
|
@ -875,7 +876,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::NsNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::NsNotFound {
|
||||||
value: ns.to_owned(),
|
value: ns.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineNamespaceStatement = val.into();
|
let val: DefineNamespaceStatement = val.into();
|
||||||
|
@ -895,7 +896,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::UserNsNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::UserNsNotFound {
|
||||||
value: us.to_owned(),
|
value: us.to_owned(),
|
||||||
ns: ns.to_owned(),
|
ns: ns.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
|
@ -920,7 +921,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::AccessNsNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::AccessNsNotFound {
|
||||||
ac: na.to_owned(),
|
ac: na.to_owned(),
|
||||||
ns: ns.to_owned(),
|
ns: ns.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
|
@ -946,7 +947,8 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::AccessGrantNsNotFound {
|
let val =
|
||||||
|
self.get(key, None).await?.ok_or_else(|| Error::AccessGrantNsNotFound {
|
||||||
ac: ac.to_owned(),
|
ac: ac.to_owned(),
|
||||||
gr: gr.to_owned(),
|
gr: gr.to_owned(),
|
||||||
ns: ns.to_owned(),
|
ns: ns.to_owned(),
|
||||||
|
@ -968,7 +970,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::DbNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::DbNotFound {
|
||||||
value: db.to_owned(),
|
value: db.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineDatabaseStatement = val.into();
|
let val: DefineDatabaseStatement = val.into();
|
||||||
|
@ -993,7 +995,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::UserDbNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::UserDbNotFound {
|
||||||
value: us.to_owned(),
|
value: us.to_owned(),
|
||||||
ns: ns.to_owned(),
|
ns: ns.to_owned(),
|
||||||
db: db.to_owned(),
|
db: db.to_owned(),
|
||||||
|
@ -1020,7 +1022,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::AccessDbNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::AccessDbNotFound {
|
||||||
ac: da.to_owned(),
|
ac: da.to_owned(),
|
||||||
ns: ns.to_owned(),
|
ns: ns.to_owned(),
|
||||||
db: db.to_owned(),
|
db: db.to_owned(),
|
||||||
|
@ -1048,7 +1050,8 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::AccessGrantDbNotFound {
|
let val =
|
||||||
|
self.get(key, None).await?.ok_or_else(|| Error::AccessGrantDbNotFound {
|
||||||
ac: ac.to_owned(),
|
ac: ac.to_owned(),
|
||||||
gr: gr.to_owned(),
|
gr: gr.to_owned(),
|
||||||
ns: ns.to_owned(),
|
ns: ns.to_owned(),
|
||||||
|
@ -1077,7 +1080,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::MlNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::MlNotFound {
|
||||||
value: format!("{ml}<{vn}>"),
|
value: format!("{ml}<{vn}>"),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineModelStatement = val.into();
|
let val: DefineModelStatement = val.into();
|
||||||
|
@ -1102,7 +1105,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::AzNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::AzNotFound {
|
||||||
value: az.to_owned(),
|
value: az.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineAnalyzerStatement = val.into();
|
let val: DefineAnalyzerStatement = val.into();
|
||||||
|
@ -1127,7 +1130,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::FcNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::FcNotFound {
|
||||||
value: fc.to_owned(),
|
value: fc.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineFunctionStatement = val.into();
|
let val: DefineFunctionStatement = val.into();
|
||||||
|
@ -1152,7 +1155,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::PaNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::PaNotFound {
|
||||||
value: pa.to_owned(),
|
value: pa.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineParamStatement = val.into();
|
let val: DefineParamStatement = val.into();
|
||||||
|
@ -1177,7 +1180,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::TbNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::TbNotFound {
|
||||||
value: tb.to_owned(),
|
value: tb.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineTableStatement = val.into();
|
let val: DefineTableStatement = val.into();
|
||||||
|
@ -1203,7 +1206,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::EvNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::EvNotFound {
|
||||||
value: ev.to_owned(),
|
value: ev.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineEventStatement = val.into();
|
let val: DefineEventStatement = val.into();
|
||||||
|
@ -1229,7 +1232,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::FdNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::FdNotFound {
|
||||||
value: fd.to_owned(),
|
value: fd.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineFieldStatement = val.into();
|
let val: DefineFieldStatement = val.into();
|
||||||
|
@ -1255,7 +1258,7 @@ impl Transaction {
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
let val = self.get(key, None).await?.ok_or(Error::IxNotFound {
|
let val = self.get(key, None).await?.ok_or_else(|| Error::IxNotFound {
|
||||||
value: ix.to_owned(),
|
value: ix.to_owned(),
|
||||||
})?;
|
})?;
|
||||||
let val: DefineIndexStatement = val.into();
|
let val: DefineIndexStatement = val.into();
|
||||||
|
@ -1445,7 +1448,7 @@ impl Transaction {
|
||||||
// The entry is not in the cache
|
// The entry is not in the cache
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
// Try to fetch the value from the datastore
|
// Try to fetch the value from the datastore
|
||||||
let res = self.get(&key, None).await?.ok_or(Error::NsNotFound {
|
let res = self.get(&key, None).await?.ok_or_else(|| Error::NsNotFound {
|
||||||
value: ns.to_owned(),
|
value: ns.to_owned(),
|
||||||
});
|
});
|
||||||
// Check whether the value exists in the datastore
|
// Check whether the value exists in the datastore
|
||||||
|
@ -1498,7 +1501,7 @@ impl Transaction {
|
||||||
// The entry is not in the cache
|
// The entry is not in the cache
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
// Try to fetch the value from the datastore
|
// Try to fetch the value from the datastore
|
||||||
let res = self.get(&key, None).await?.ok_or(Error::DbNotFound {
|
let res = self.get(&key, None).await?.ok_or_else(|| Error::DbNotFound {
|
||||||
value: db.to_owned(),
|
value: db.to_owned(),
|
||||||
});
|
});
|
||||||
// Check whether the value exists in the datastore
|
// Check whether the value exists in the datastore
|
||||||
|
@ -1566,7 +1569,7 @@ impl Transaction {
|
||||||
// The entry is not in the cache
|
// The entry is not in the cache
|
||||||
Err(cache) => {
|
Err(cache) => {
|
||||||
// Try to fetch the value from the datastore
|
// Try to fetch the value from the datastore
|
||||||
let res = self.get(&key, None).await?.ok_or(Error::TbNotFound {
|
let res = self.get(&key, None).await?.ok_or_else(|| Error::TbNotFound {
|
||||||
value: tb.to_owned(),
|
value: tb.to_owned(),
|
||||||
});
|
});
|
||||||
// Check whether the value exists in the datastore
|
// Check whether the value exists in the datastore
|
||||||
|
|
Loading…
Reference in a new issue