forked from ravinet/mahimahi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexception.hh
35 lines (26 loc) · 813 Bytes
/
exception.hh
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
/* -*-mode:c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef EXCEPTION_HH
#define EXCEPTION_HH
#include <string>
#include <iostream>
#include <cstring>
class Exception
{
private:
std::string attempt_, error_;
public:
Exception( const std::string s_attempt, const std::string s_error )
: attempt_( s_attempt ), error_( s_error )
{}
Exception( const std::string s_attempt )
: attempt_( s_attempt ), error_( strerror( errno ) )
{}
void perror( void ) const
{
std::cerr << attempt_ << ": " << error_ << std::endl << std::flush;
}
const std::string & attempt( void ) const { return attempt_; }
};
/* error-checking wrapper for most syscalls */
int SystemCall( const std::string & s_attempt, const int return_value );
#endif