diff options
Diffstat (limited to 'cpp/rubygen/0-10/exceptions.rb')
-rwxr-xr-x | cpp/rubygen/0-10/exceptions.rb | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/cpp/rubygen/0-10/exceptions.rb b/cpp/rubygen/0-10/exceptions.rb index 4f7080690f..2f62b2ccdf 100755 --- a/cpp/rubygen/0-10/exceptions.rb +++ b/cpp/rubygen/0-10/exceptions.rb @@ -10,17 +10,37 @@ class GenExceptions < CppGen @dir="qpid/amqp_#{@amqp.version.bars}" end + def exceptions_for_enum(enum, base, ns, suffix="") + enum.choices.each { |c| + name=c.name.typename+suffix+"Exception" + genl + doxygen_comment { genl c.doc } + struct(name, "public #{base}") { + genl "#{name}(const std::string& msg=std::string())" + genl " : #{base}(#{ns}::#{c.name.shout}, msg) {}" + protected + genl "std::string getPrefix() const { return \"#{name}\"; }" + } + } + end + def gen_exceptions() h_file("#{@dir}/exceptions") { - include "qpid/Exception" - include "specification.h" + include "qpid/amqp_0_10/Exception" namespace("#{@ns}") { - @amqp.class_("execution").domain("error-code").enum.choices.each { |c| - name=c.name.typename+"Exception" - struct(name, "public SessionException") { - genl "#{name}(const std::string& msg=std::string()) : SessionException(execution::#{c.name.shout}, msg) {}" - } - } + error_code = @amqp.class_("execution").domain("error-code").enum + exceptions_for_enum(error_code, "SessionAbortedException", "execution") + genl + + detach_code = @amqp.class_("session").domain("detach-code").enum + exceptions_for_enum(detach_code, "SessionDetachedException", "session", "Detached") + + genl + exceptions_for_enum(detach_code, "SessionExpiredException", "session", "Expired") + genl + + close_code = @amqp.class_("connection").domain("close-code").enum + exceptions_for_enum(close_code, "ConnectionException", "connection") } } end |