summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-05-05 21:04:33 +0000
committerChris Wilson <chris+github@qwirx.com>2008-05-05 21:04:33 +0000
commit3a12683ce29e7157e29fac3c3b590461331e2d00 (patch)
tree60770981befb6a2592ba34c8c954b913a7182665
parent7eba897f6da8b1a993f0d40251af1748b5c793ea (diff)
Catch server errors when listing a directory.
-rw-r--r--bin/bbackupquery/BackupQueries.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index 7a7eb5cc..affac373 100644
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -410,6 +410,7 @@ void BackupQueries::CommandList(const std::vector<std::string> &args, const bool
{
BOX_ERROR("Directory '" << args[0] << "' not found "
"on store.");
+ SetReturnCode(COMMAND_RETURN_ERROR);
return;
}
}
@@ -435,11 +436,28 @@ void BackupQueries::List(int64_t DirID, const std::string &rListRoot, const bool
if(!opts[LIST_OPTION_ALLOWDELETED]) excludeFlags |= BackupProtocolClientListDirectory::Flags_Deleted;
// Do communication
- mrConnection.QueryListDirectory(
- DirID,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, // both files and directories
- excludeFlags,
- true /* want attributes */);
+ try
+ {
+ mrConnection.QueryListDirectory(
+ DirID,
+ BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
+ // both files and directories
+ excludeFlags,
+ true /* want attributes */);
+ }
+ catch (std::exception &e)
+ {
+ BOX_ERROR("Failed to list directory: " << e.what());
+ SetReturnCode(COMMAND_RETURN_ERROR);
+ return;
+ }
+ catch (...)
+ {
+ BOX_ERROR("Failed to list directory: unknown error");
+ SetReturnCode(COMMAND_RETURN_ERROR);
+ return;
+ }
+
// Retrieve the directory from the stream following
BackupStoreDirectory dir;
@@ -755,6 +773,7 @@ void BackupQueries::CommandChangeDir(const std::vector<std::string> &args, const
if(args.size() != 1 || args[0].size() == 0)
{
BOX_ERROR("Incorrect usage. cd [-o] [-d] <directory>");
+ SetReturnCode(COMMAND_RETURN_ERROR);
return;
}
@@ -772,6 +791,7 @@ void BackupQueries::CommandChangeDir(const std::vector<std::string> &args, const
if(id == 0)
{
BOX_ERROR("Directory '" << args[0] << "' not found.");
+ SetReturnCode(COMMAND_RETURN_ERROR);
return;
}