public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Search Repo:
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
FooBarWidget (author)
Fri Feb 01 12:38:11 -0800 2008
commit  a92649cae9d3a26508f13b8f2cb73694216335ac
tree    5a1f2a4c17df1cb205f4f5eedb2a1e71e245c010
parent  42b311bb9b1137922bb9d873d58cc6e7672886c2
passenger / ext / apache2 / Exceptions.h
100644 56 lines (45 sloc) 1.11 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
#ifndef _PASSENGER_EXCEPTIONS_H_
#define _PASSENGER_EXCEPTIONS_H_
 
#include <exception>
#include <string>
#include <sstream>
 
namespace Passenger {
 
using namespace std;
 
class SystemException: public exception {
private:
  string msg;
  int m_code;
public:
  SystemException(const string &message, int errorCode) {
    stringstream str(message);
    str << ":" << strerror(errorCode) << " (" << errorCode << ")";
    msg = str.str();
    m_code = errorCode;
  }
  
  virtual ~SystemException() throw() {
  }
  
  virtual const char *what() const throw() {
    return msg.c_str();
  }
  
  int code() const throw() {
    return m_code;
  }
};
 
class MemoryException: public exception {
public:
  MemoryException() {}
  virtual ~MemoryException() throw() {}
  virtual const char *what() const throw() {
    return "Unable to allocate memory.";
  }
};
 
class IOException: public exception {
private:
  string msg;
public:
  IOException(const string &message): msg(message) {}
  virtual ~IOException() throw() {}
  virtual const char *what() const throw() { return msg.c_str(); }
};
 
} // namespace Passenger
 
#endif /* _PASSENGER_EXCEPTIONS_H_ */