[6893b5]: libutil++ / op_exception.h  Maximize  Restore  History

Download this file

66 lines (55 with data), 1.6 kB

 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
61
62
63
64
65
/**
* @file op_exception.h
* exception base class
*
* This provide simple base class for exception object. All
* exception are derived from directly or indirectly from
* std::exception. This class are not itended to be catched
* in your code except at top level, derive what you want
* and catch derived class rather.
*
* @remark Copyright 2003 OProfile authors
* @remark Read the file COPYING
*
* @author Philippe Elie
* @author John Levon
*/
#ifndef OP_EXCEPTION_H
#define OP_EXCEPTION_H
#include <stdexcept>
#include <string>
/**
* exception abstract base class
*/
class op_exception : public std::exception {
public:
explicit op_exception(std::string const& msg);
~op_exception() throw() = 0;
char const * what() const throw();
private:
std::string message;
};
class op_no_samples_exception : public op_exception {
public:
explicit op_no_samples_exception(std::string const & msg);
~op_no_samples_exception() throw();
};
/**
* fatal exception, never catch it except at top level (likely main or
* gui). Intended to replace cerr << "blah"; exit(EXIT_FAILURE); by a
* throw op_fatal_error("blah") when returning error code is not an option
*/
struct op_fatal_error : op_exception
{
explicit op_fatal_error(std::string const & msg);
};
/**
* Encapsulate a runtime error with or w/o a valid errno
*/
struct op_runtime_error : std::runtime_error
{
explicit op_runtime_error(std::string const & err);
op_runtime_error(std::string const & err, int cerrno);
~op_runtime_error() throw();
};
#endif /* !OP_EXCEPTION_H */

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks