Improve error handling

This commit is contained in:
William Brown 2019-02-26 14:38:12 +10:00
parent b729dc31c1
commit 16ca6f3116
3 changed files with 39 additions and 33 deletions

View file

@ -349,6 +349,7 @@ impl BackendWriteTransaction {
entries: &Vec<Entry<EntryValid, EntryCommitted>>, entries: &Vec<Entry<EntryValid, EntryCommitted>>,
) -> Result<(), BackendError> { ) -> Result<(), BackendError> {
// Perform a search for the entries --> This is a problem for the caller // Perform a search for the entries --> This is a problem for the caller
audit_segment!(au, || {
if entries.is_empty() { if entries.is_empty() {
// TODO: Better error // TODO: Better error
@ -382,6 +383,7 @@ impl BackendWriteTransaction {
} }
Ok(()) Ok(())
})
} }
pub fn backup(&self) -> Result<(), BackendError> { pub fn backup(&self) -> Result<(), BackendError> {
@ -422,7 +424,7 @@ impl BackendWriteTransaction {
} }
} }
pub fn setup(&self, audit: &mut AuditScope) -> Result<(), ()> { pub fn setup(&self, audit: &mut AuditScope) -> Result<(), OperationError> {
{ {
// self.conn.execute("BEGIN TRANSACTION", NO_PARAMS).unwrap(); // self.conn.execute("BEGIN TRANSACTION", NO_PARAMS).unwrap();
@ -511,8 +513,10 @@ impl Backend {
// Now complete our setup with a txn // Now complete our setup with a txn
let r = { let r = {
let be_txn = be.write(); let be_txn = be.write();
be_txn.setup(audit); be_txn.setup(audit)
.and_then(|_| {
be_txn.commit() be_txn.commit()
})
}; };
audit_log!(audit, "be new setup: {:?}", r); audit_log!(audit, "be new setup: {:?}", r);

View file

@ -124,7 +124,7 @@ impl Filter<FilterInvalid> {
let attr_norm = schema_name.normalise_value(attr); let attr_norm = schema_name.normalise_value(attr);
// Now check it exists // Now check it exists
match schema_attributes.get(&attr_norm) { match schema_attributes.get(&attr_norm) {
Some(schema_a) => { Some(_attr_name) => {
// Return our valid data // Return our valid data
Ok(Filter::Pres(attr_norm)) Ok(Filter::Pres(attr_norm))
} }

View file

@ -82,9 +82,11 @@ pub fn start(log: actix::Addr<EventLog>, path: &str, threads: usize) -> Result<a
let mut audit_qsc = AuditScope::new("query_server_init"); let mut audit_qsc = AuditScope::new("query_server_init");
let query_server_write = query_server.write(); let query_server_write = query_server.write();
query_server_write.initialise(&mut audit_qsc); match query_server_write.initialise(&mut audit_qsc)
.and_then(|_| {
audit_segment!(audit_qsc, || query_server_write.commit(&mut audit_qsc))
}) {
// We are good to go! Finally commit and consume the txn. // We are good to go! Finally commit and consume the txn.
match audit_segment!(audit_qsc, || query_server_write.commit(&mut audit_qsc)) {
Ok(_) => {} Ok(_) => {}
Err(e) => return Err(e), Err(e) => return Err(e),
}; };
@ -838,7 +840,7 @@ impl<'a> QueryServerWriteTransaction<'a> {
audit_log!(audit, "Generated modlist -> {:?}", modlist); audit_log!(audit, "Generated modlist -> {:?}", modlist);
self.internal_modify(audit, filt, modlist) self.internal_modify(audit, filt, modlist)
} }
Err(e) => { Err(_e) => {
unimplemented!() unimplemented!()
// No action required. // No action required.
} }