-
Notifications
You must be signed in to change notification settings - Fork 295
/
Copy pathkhmer_exception.hh
73 lines (60 loc) · 1.68 KB
/
khmer_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
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
66
67
68
69
70
71
72
73
//
// This file is part of khmer, http://github.com/ged-lab/khmer/, and is
// Copyright (C) Michigan State University, 2009-2013. It is licensed under
// the three-clause BSD license; see doc/LICENSE.txt.
// Contact: khmer-project@idyll.org
//
#ifndef KHMER_EXCEPTION_HH
#define KHMER_EXCEPTION_HH
#include <exception>
#include <string>
namespace khmer
{
///
// A base class for all exceptions.
//
// All exceptions should be derived from this base class.
//
class khmer_exception : public std::exception
{
public:
explicit khmer_exception(const char * msg) : _msg(msg) { }
explicit khmer_exception(const std::string& msg = "Generic khmer exception")
: _msg(msg.c_str()) { }
virtual ~khmer_exception() throw() { }
virtual const char* what() const throw ()
{
return _msg;
}
protected:
const char * _msg;
};
///
// A base class for file exceptions.
//
class khmer_file_exception : public khmer_exception
{
public:
explicit khmer_file_exception(const char * msg) : khmer_exception(msg) { }
explicit khmer_file_exception(const std::string& msg)
: khmer_exception(msg) { }
};
struct InvalidStreamBuffer : public khmer_exception {
};
class InvalidStreamHandle : public khmer_file_exception
{
public:
InvalidStreamHandle()
: khmer_file_exception("Generic InvalidStreamHandle error") {}
InvalidStreamHandle(const char * msg) : khmer_file_exception(msg) {}
};
class StreamReadError : public khmer_file_exception
{
public:
StreamReadError()
: khmer_file_exception("Generic StreamReadError error") {}
StreamReadError(const char * msg) : khmer_file_exception(msg) {}
};
}
#endif // KHMER_EXCEPTION_HH
// vim: set sts=2 sw=2: