summaryrefslogtreecommitdiff
path: root/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp')
-rw-r--r--ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp b/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
new file mode 100644
index 00000000000..ba5944404f0
--- /dev/null
+++ b/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
@@ -0,0 +1,58 @@
+// file : Example/ExH/LogicToSystem/logic_to_system.cpp
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2002-2003 Boris Kolpackov
+// license : http://kolpackov.net/license.html
+
+#include "Utility/ExH/System/Exception.hpp"
+#include "Utility/ExH/Logic/Exception.hpp"
+
+#include <iostream>
+
+using std::cerr;
+using std::endl;
+
+
+struct SubsystemA
+{
+ class Exception : public Utility::ExH::Logic::Exception {};
+
+ void
+ foo () throw (Exception)
+ {
+ throw Exception ();
+ }
+};
+
+
+struct SubsystemB
+{
+ void
+ foo () throw (Utility::ExH::System::Exception)
+ {
+ SubsystemA a;
+ a.foo ();
+
+ // Here SubsystemB is using SunsystemA but cannot (forgot, doesnt't
+ // want to, doesn't know how to, etc - pick your favorite) handle
+ // exception thrown by SubsystemA. As a result exception is
+ // 'converted' to System::Exception.
+ }
+};
+
+
+int
+main ()
+{
+ try
+ {
+ SubsystemB b;
+ b.foo ();
+ }
+ catch (Utility::ExH::System::Exception const& ex)
+ {
+ cerr << "Caught Utility::ExH::System::Exception: "
+ << ex.what ()
+ << endl;
+ }
+}
+//$Id$