From 65694550d9352879befaa80a4dc9553e8d359310 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 9 Apr 2014 22:14:54 +0000 Subject: Add a static GetMessage() to BackupProtocolError. Allows retrieving the error message for a given code, when we no longer have the protocol object handy. Conflicts: lib/server/makeprotocol.pl.in --- lib/server/makeprotocol.pl.in | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/server/makeprotocol.pl.in b/lib/server/makeprotocol.pl.in index db9764fb..8765c301 100755 --- a/lib/server/makeprotocol.pl.in +++ b/lib/server/makeprotocol.pl.in @@ -323,8 +323,13 @@ __E if(obj_is_type($cmd,'IsError')) { - print H "\tbool IsError(int &rTypeOut, int &rSubTypeOut) const;\n"; - print H "\tstd::string GetMessage() const;\n"; + $error_message = $cmd; + my ($mem_type,$mem_subtype) = split /,/,obj_get_type_params($cmd,'IsError'); + print H <<__E; + bool IsError(int &rTypeOut, int &rSubTypeOut) const; + std::string GetMessage() const { return GetMessage(m$mem_subtype); }; + static std::string GetMessage(int subtype); +__E } my $has_stream = obj_is_type($cmd, 'StreamWithCommand'); @@ -496,9 +501,9 @@ bool $cmd_class\::IsError(int &rTypeOut, int &rSubTypeOut) const rSubTypeOut = m$mem_subtype; return true; } -std::string $cmd_class\::GetMessage() const +std::string $cmd_class\::GetMessage(int subtype) { - switch(m$mem_subtype) + switch(subtype) { __E foreach my $const (@{$cmd_constants{$cmd}}) @@ -513,7 +518,7 @@ __E print CPP <<__E; default: std::ostringstream out; - out << "Unknown subtype " << m$mem_subtype; + out << "Unknown subtype " << subtype; return out.str(); } } @@ -669,6 +674,7 @@ void $callable_base_class\::CheckReply(const std::string& requestCommandName, if(rReply.GetType() == expectedType) { // Correct response, do nothing + SetLastError(Protocol::NoError, Protocol::NoError); } else { -- cgit v1.2.3