Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
exceptions.h
Go to the documentation of this file.
1 #ifndef gamgee__exceptions__guard
2 #define gamgee__exceptions__guard
3 
4 #include <boost/format.hpp>
5 
6 #include <exception>
7 #include <string>
8 
9 namespace gamgee {
10 
14 class FileOpenException : public std::runtime_error {
15  public:
16  FileOpenException(const std::string& filename) :
17  std::runtime_error{std::string{"Could not open file "} + filename} {}
18 };
19 
23 class IndexLoadException : public std::runtime_error {
24  public:
25  IndexLoadException(const std::string& filename) :
26  std::runtime_error{std::string{"Could not open index for file "} + filename} {}
27 };
28 
32 class HeaderReadException : public std::runtime_error {
33  public:
34  HeaderReadException(const std::string& filename) :
35  std::runtime_error{std::string{"Could not read header for file "} + filename} {}
36 };
37 
41 class HeaderCompatibilityException : public std::runtime_error {
42  public:
43  HeaderCompatibilityException(const std::string& reason) :
44  std::runtime_error(std::string{"Incompatible headers: "} + reason) { }
45 };
46 
50 class SingleInputException : public std::runtime_error {
51  public:
52  SingleInputException(const std::string& vector_name, const size_t size) :
53  std::runtime_error{(boost::format("Error: single input required, but vector %s has size %d") % vector_name % size).str()} { }
54 };
55 
59 class HtslibException : public std::runtime_error {
60  public:
61  HtslibException(const int error_code) :
62  std::runtime_error{(boost::format("Error: htslib failed with error code %d. See stderr for details.") % error_code).str()} { }
63 };
64 
68 class ChromosomeNotFoundException : public std::runtime_error {
69  public:
70  ChromosomeNotFoundException(const std::string& chrom_name) :
71  std::runtime_error{(boost::format("Error: chromosome %s was not found in the given reference") % chrom_name).str()} { }
72 };
73 
77 class ChromosomeSizeException : public std::runtime_error {
78  public:
79  ChromosomeSizeException(const std::string& chrom_name, const size_t chrom_size, const int desired_location) :
80  std::runtime_error{(boost::format("Error: chromosome %s is of size %d but location %d was requested") % chrom_name % chrom_size % desired_location).str()} { }
81 };
82 
83 } // end of namespace gamgee
84 
85 #endif // end of gamgee__exceptions__guard
86 
SingleInputException(const std::string &vector_name, const size_t size)
Definition: exceptions.h:52
HtslibException(const int error_code)
Definition: exceptions.h:61
FileOpenException(const std::string &filename)
Definition: exceptions.h:16
an exception class for the case where a chromosome is not found in the reference
Definition: exceptions.h:68
HeaderCompatibilityException(const std::string &reason)
Definition: exceptions.h:43
HeaderReadException(const std::string &filename)
Definition: exceptions.h:34
Exception for the case where there is an error opening a file for reading/writing.
Definition: exceptions.h:14
ChromosomeSizeException(const std::string &chrom_name, const size_t chrom_size, const int desired_location)
Definition: exceptions.h:79
ChromosomeNotFoundException(const std::string &chrom_name)
Definition: exceptions.h:70
an exception class for the case where a single input is required, but more is provided ...
Definition: exceptions.h:50
#define str(x)
Definition: sam.c:66
Exception for the case where multiple headers are incompatible in some way.
Definition: exceptions.h:41
an exception class for the case where a chromosome is not found in the reference
Definition: exceptions.h:77
Definition: exceptions.h:9
Exception for the case where a file header could not be read.
Definition: exceptions.h:32
Exception for the case where an index file cannot be opened for a particular file (eg...
Definition: exceptions.h:23
a catchall exception class for htslib errors
Definition: exceptions.h:59
IndexLoadException(const std::string &filename)
Definition: exceptions.h:25