Statistics
| Branch: | Revision:

root / src / common / exception.h @ e1750c09

History | View | Annotate | Download (1.42 KB)

1
//=========================================================================
2
//  EXCEPTION.H - part of
3
//                  OMNeT++/OMNEST
4
//           Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//=========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16

    
17
#ifndef _EXCEPTION_H_
18
#define _EXCEPTION_H_
19

    
20
#include <string>
21
#include <exception>
22
#include <stdexcept>
23
#include "commondefs.h"
24

    
25
NAMESPACE_BEGIN
26

    
27
//FIXME rename this file
28

    
29
/**
30
 * Utility class: makes std::runtime_error somewhat more convenient to use,
31
 * by providing a printf-style constructor. Catch as std::runtime_error.
32
 */
33
class COMMON_API opp_runtime_error : public std::runtime_error
34
{
35
  protected:
36
    std::string errormsg;
37

    
38
  public:
39
    /**
40
     * The error message can be generated in a printf-like manner.
41
     */
42
    opp_runtime_error(const char *msg,...);
43

    
44
    /**
45
     * Destructor with throw clause required by gcc.
46
     */
47
    virtual ~opp_runtime_error() throw() {}
48

    
49
    /**
50
     * Returns the text of the error. Redefined from std::exception.
51
     */
52
    virtual const char *what() const throw() {return errormsg.c_str();}
53
};
54

    
55
NAMESPACE_END
56

    
57

    
58
#endif
59

    
60