From 3a12683ce29e7157e29fac3c3b590461331e2d00 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 5 May 2008 21:04:33 +0000 Subject: Catch server errors when listing a directory. --- bin/bbackupquery/BackupQueries.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'bin') 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 &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 &args, const if(args.size() != 1 || args[0].size() == 0) { BOX_ERROR("Incorrect usage. cd [-o] [-d] "); + SetReturnCode(COMMAND_RETURN_ERROR); return; } @@ -772,6 +791,7 @@ void BackupQueries::CommandChangeDir(const std::vector &args, const if(id == 0) { BOX_ERROR("Directory '" << args[0] << "' not found."); + SetReturnCode(COMMAND_RETURN_ERROR); return; } -- cgit v1.2.3