summaryrefslogtreecommitdiff
path: root/lib/backupstore
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-08-15 10:57:59 +0000
committerChris Wilson <chris+github@qwirx.com>2015-08-15 10:57:59 +0000
commitfeade829d345bd6e34f39dfc32498696e6f588a1 (patch)
tree84faf18ef5e1cc9c9bd6eba36946db6a7dfff0f2 /lib/backupstore
parent62c0689012de2786ed2fae3da84b5301d6b49a55 (diff)
Improve exception handling on backup store side.
Add a new exception code to represent an object being completely missing (not found on the store at all), separate from not being found in a particular directory. Improve mapping of server-side exceptions to protocol error messages returned to the client. Add handling for missing exceptions, such as BackupStoreException::PatchChainInfoBadInDirectory, and the new BackupStoreException::ObjectDoesNotExist. Fix mapping for BackupStoreException::CouldNotFindEntryInDirectory to make it distinguistable from BackupStoreException::ObjectDoesNotExist.
Diffstat (limited to 'lib/backupstore')
-rw-r--r--lib/backupstore/BackupCommands.cpp33
-rw-r--r--lib/backupstore/BackupStoreException.txt1
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/backupstore/BackupCommands.cpp b/lib/backupstore/BackupCommands.cpp
index ab0dc4b8..22ef0215 100644
--- a/lib/backupstore/BackupCommands.cpp
+++ b/lib/backupstore/BackupCommands.cpp
@@ -85,12 +85,20 @@ std::auto_ptr<BackupProtocolMessage> BackupProtocolReplyable::HandleException(Bo
}
else if(e.GetSubType() == BackupStoreException::CouldNotFindEntryInDirectory)
{
- return PROTOCOL_ERROR(Err_DoesNotExist);
+ return PROTOCOL_ERROR(Err_DoesNotExistInDirectory);
}
else if(e.GetSubType() == BackupStoreException::NameAlreadyExistsInDirectory)
{
return PROTOCOL_ERROR(Err_TargetNameExists);
}
+ else if(e.GetSubType() == BackupStoreException::ObjectDoesNotExist)
+ {
+ return PROTOCOL_ERROR(Err_DoesNotExist);
+ }
+ else if(e.GetSubType() == BackupStoreException::PatchChainInfoBadInDirectory)
+ {
+ return PROTOCOL_ERROR(Err_PatchConsistencyError);
+ }
}
throw;
@@ -779,7 +787,28 @@ std::auto_ptr<BackupProtocolMessage> BackupProtocolGetObjectName::DoCommand(Back
}
// Load up the directory
- const BackupStoreDirectory &rdir(rContext.GetDirectory(dirID));
+ const BackupStoreDirectory *pDir;
+
+ try
+ {
+ pDir = &rContext.GetDirectory(dirID);
+ }
+ catch(BackupStoreException &e)
+ {
+ if(e.GetSubType() == BackupStoreException::ObjectDoesNotExist)
+ {
+ // If this can't be found, then there is a problem...
+ // tell the caller it can't be found.
+ return std::auto_ptr<BackupProtocolMessage>(
+ new BackupProtocolObjectName(
+ BackupProtocolObjectName::NumNameElements_ObjectDoesntExist,
+ 0, 0, 0));
+ }
+
+ throw;
+ }
+
+ const BackupStoreDirectory& rdir(*pDir);
// Find the element in this directory and store it's name
if(objectID != ObjectID_DirectoryOnly)
diff --git a/lib/backupstore/BackupStoreException.txt b/lib/backupstore/BackupStoreException.txt
index b49a9cf2..40232a8e 100644
--- a/lib/backupstore/BackupStoreException.txt
+++ b/lib/backupstore/BackupStoreException.txt
@@ -72,3 +72,4 @@ UnknownObjectRefCountRequested 68 A reference count was requested for an object
MultiplyReferencedObject 69 Attempted to modify an object with multiple references, should be uncloned first
CorruptReferenceCountDatabase 70 The account's refcount database is corrupt and must be rebuilt by housekeeping.
CancelledByBackgroundTask 71 The current task was cancelled on request by the background task.
+ObjectDoesNotExist 72 The specified object ID does not exist in the store.