summaryrefslogtreecommitdiff
path: root/ACE/contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp
blob: 6f718e9c6947a69fa4fb5a0ac23103e61282ce36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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

/* FUZZ: disable check_for_improper_main_declaration */

#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 ();
  }
};


struct SubsystemB
{
  void
  foo ()
  {
    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$