src/work/klao/error2_test.cc
changeset 1365 c280de819a73
parent 1364 ee5959aa4410
child 1366 d00b85f8be45
     1.1 --- a/src/work/klao/error2_test.cc	Sun Apr 17 18:57:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,68 +0,0 @@
     1.4 -#include <iostream>
     1.5 -#include <memory>
     1.6 -
     1.7 -#include <boost/shared_ptr.hpp>
     1.8 -
     1.9 -using namespace std;
    1.10 -
    1.11 -class Ex : public exception {
    1.12 -
    1.13 -  typedef exception Parent;
    1.14 -
    1.15 -  mutable
    1.16 -  auto_ptr<string> uz;
    1.17 -public:
    1.18 -
    1.19 -  // boost::shared_ptr<string> uz;
    1.20 -
    1.21 -  Ex(const Ex &e) : Parent(e), uz(e.uz) {}
    1.22 -
    1.23 -  explicit
    1.24 -  Ex(const char *msg = 0) {
    1.25 -    if( msg ) {
    1.26 -      try {
    1.27 -	uz.reset(new string);
    1.28 -	*uz = msg;
    1.29 -      }
    1.30 -      catch(...) {
    1.31 -	uz.reset();
    1.32 -      }
    1.33 -    }
    1.34 -  }
    1.35 -
    1.36 -  virtual
    1.37 -  const char* what() const throw() {
    1.38 -    if( uz.get() )
    1.39 -      return uz->c_str();
    1.40 -    return "Kivetel";
    1.41 -  }
    1.42 -
    1.43 -  virtual ~Ex() throw() {}
    1.44 -};
    1.45 -
    1.46 -static void fn1() {
    1.47 -  Ex e("alma");
    1.48 -  throw e;
    1.49 -}
    1.50 -
    1.51 -static
    1.52 -void fn2() {
    1.53 -  throw Ex("korte");
    1.54 -}
    1.55 -
    1.56 -int main() {
    1.57 -  try {
    1.58 -    fn1();
    1.59 -  }
    1.60 -  catch(exception const &e) {
    1.61 -    cerr << "Hiba: " << e.what() << endl;
    1.62 -  }
    1.63 -
    1.64 -  try {
    1.65 -    fn2();
    1.66 -  }
    1.67 -  catch(exception const &e) {
    1.68 -    cerr << "Hiba: " << e.what() << endl;
    1.69 -  }
    1.70 -
    1.71 -}