Skip to content

Commit

Permalink
All exceptions defined in khmer are derived class from khmer::khmer_e…
Browse files Browse the repository at this point in the history
…xception,

including khmer::khmer_file_exception.
  • Loading branch information
iglpdc committed Jul 22, 2014
1 parent 8d6b1cc commit 92135e8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/khmer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ __attribute__((cpychecker_type_object_for_typedef(typename)))
# define MIN( a, b ) (((a) > (b)) ? (b) : (a))
# define MAX( a, b ) (((a) < (b)) ? (b) : (a))

#include <khmer_exception.hh>
#include "khmer_exception.hh"
namespace khmer
{
// largest number we can count up to, exactly. (8 bytes)
Expand All @@ -79,7 +79,7 @@ typedef void (*CallbackFn)(const char * info, void * callback_data,
unsigned long long n_reads,
unsigned long long other);

struct InvalidStreamBuffer : public std:: exception {
struct InvalidStreamBuffer : public khmer_exception {
};


Expand Down
18 changes: 13 additions & 5 deletions lib/khmer_exception.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define KHMER_EXCEPTION_HH

#include <exception>
#include <string>

namespace khmer
{
Expand All @@ -21,19 +22,26 @@ namespace khmer
class khmer_exception : public std::exception
{
public:
khmer_exception(const char * msg) : _msg(msg) { };
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; }

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:
khmer_file_exception(const char * msg) : khmer_exception(msg) { };
explicit khmer_file_exception(const char * msg) : khmer_exception(msg) { }
explicit khmer_file_exception(const std::string& msg)
: khmer_exception(msg) { }
};

}
Expand Down
4 changes: 1 addition & 3 deletions lib/perf_metrics.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
#include <cstring>
#include <ctime>

#include <exception>

#include "khmer.hh"


namespace khmer
{

#ifdef WITH_INTERNAL_METRICS
struct InvalidPerformanceMetricsKey : public std:: exception {
struct InvalidPerformanceMetricsKey : public khmer_exception {
};


Expand Down
12 changes: 6 additions & 6 deletions lib/read_parsers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ public:

};

struct CacheSegmentUnavailable : public std:: exception {
struct CacheSegmentUnavailable : public khmer_exception {
};

struct CacheSegmentBoundaryViolation : public std:: exception {
struct CacheSegmentBoundaryViolation : public khmer_exception {
};

struct InvalidCacheSizeRequested : public std:: exception {
struct InvalidCacheSizeRequested : public khmer_exception {
};

struct NoMoreReadsAvailable : public std:: exception {
struct NoMoreReadsAvailable : public khmer_exception {
};

struct UnknownPairReadingMode : public std:: exception {
struct UnknownPairReadingMode : public khmer_exception {
};

struct InvalidReadPair : public std:: exception {
struct InvalidReadPair : public khmer_exception {
};

#ifdef WITH_INTERNAL_METRICS
Expand Down
5 changes: 2 additions & 3 deletions lib/thread_id_map.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#ifndef THREAD_ID_MAP_HH
# define THREAD_ID_MAP_HH

#include <exception>
#include <map>

// TODO? Just use 'pthread_t' everywhere.
Expand All @@ -31,10 +30,10 @@ namespace khmer
{


struct InvalidNumberOfThreadsRequested : public std:: exception {
struct InvalidNumberOfThreadsRequested : public khmer_exception {
};

struct TooManyThreads : public std:: exception {
struct TooManyThreads : public khmer_exception {
};


Expand Down

0 comments on commit 92135e8

Please sign in to comment.