summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/Gen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index e61c0f838d9..8e3ab81235b 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -200,7 +200,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
string scoped = p->scoped();
ExceptionPtr base = p->base();
- H << sp << nl << "struct " << name << " : ";
+ H << sp << nl << "class " << name << " : ";
H.useCurrentPosAsIndent();
if (!base)
{
@@ -220,6 +220,10 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
H.restoreIndent();
H << sb;
+ H.dec();
+ H << nl << "public: ";
+ H.inc();
+
if (p->isLocal())
{
H << nl << _dllExport << name << "(const char*, int);";
@@ -1139,8 +1143,6 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
C << sb;
if (!throws.empty())
{
- // TODO: pretty hacky, should be statically initialized, once
- // per operation.
ExceptionList::const_iterator r;
C << nl << "static const char* __throws[] =";
C << sb;
@@ -1341,6 +1343,8 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
C << sb;
C << nl << "throw ::Ice::OperationNotExistException(__FILE__, __LINE__);";
C << eb;
+ C << nl << "try";
+ C << sb;
C << nl;
if (ret)
{
@@ -1348,6 +1352,30 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
}
C << "__servant->" << name << args << ';';
C << eb;
+ ExceptionList throws = p->throws();
+ throws.sort();
+ throws.unique();
+ ExceptionList::const_iterator r;
+ for (r = throws.begin(); r != throws.end(); ++r)
+ {
+ C << nl << "catch (const " << (*r)->scoped() << "&)";
+ C << sb;
+ C << nl << "throw;";
+ C << eb;
+ }
+ C << nl << "catch (const ::Ice::LocalException&)";
+ C << sb;
+ C << nl << "throw ::Ice::UnknownLocalException(__FILE__, __LINE__);";
+ C << eb;
+ C << nl << "catch (const ::Ice::UserException&)";
+ C << sb;
+ C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);";
+ C << eb;
+ C << nl << "catch (...)";
+ C << sb;
+ C << nl << "throw ::Ice::UnknownException(__FILE__, __LINE__);";
+ C << eb;
+ C << eb;
}
Slice::Gen::ObjectDeclVisitor::ObjectDeclVisitor(Output& h, Output& c, const string& dllExport) :
@@ -1864,7 +1892,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
ExceptionList::const_iterator r;
for (r = throws.begin(); r != throws.end(); ++r)
{
- C << nl << "catch(const " << (*r)->scoped() << "& __ex)";
+ C << nl << "catch (const " << (*r)->scoped() << "& __ex)";
C << sb;
C << nl << "__os->write(__ex);";
C << nl << "return ::IceInternal::DispatchUserException;";