Image Component Library (ICL)
Exception.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLUtils/src/ICLUtils/Exception.h **
10 ** Module : ICLUtils **
11 ** Authors: Christof Elbrechter, Michael Goetting, Robert Haschke **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <iostream>
35 #include <exception>
36 #include <string>
37 #include <stdexcept>
38 
39 namespace icl {
40  namespace utils{
42  class ICLException : public std::runtime_error
43  {
44  public:
45  ICLException(const std::string &msg) throw() : runtime_error(msg){}
46  ICLUtils_API void report();
47  };
48 
51  public:
53  ICLException ("invalid file format") {}
54  InvalidFileFormatException (const std::string &hint) throw() :
55  ICLException ("invalid file format :(" + hint + ")") {}
56  virtual ~InvalidFileFormatException() throw() {}
57  };
58 
61  public:
62  FileOpenException (const std::string& sFileName) throw() :
63  ICLException (std::string("Can't open file: ") + sFileName) {}
64  virtual ~FileOpenException() throw() {}
65  };
66 
69  public:
70  FileNotFoundException (const std::string& sFileName) throw() :
71  ICLException (std::string("File not found: ") + sFileName) {}
72  virtual ~FileNotFoundException() throw() {}
73  };
74 
77  public:
78  InvalidFileException (const std::string& sFileName) throw() :
79  ICLException (std::string("Invalied file: ") + sFileName) {}
80  virtual ~InvalidFileException() throw() {}
81  };
82 
85  public:
86  InvalidImgParamException(const std::string &param) throw():
87  ICLException(std::string("Invalid Img-Parameter: ")+param) {}
88  virtual ~InvalidImgParamException() throw() {}
89  };
90 
93  public:
94  InvalidFormatException(const std::string &functionName) throw():
95  ICLException(std::string("Invalid Format in: ")+functionName) {}
96  virtual ~InvalidFormatException() throw() {}
97  };
98 
101  public:
102  InvalidDepthException(const std::string &functionName) throw():
103  ICLException(std::string("Invalid Depth in: ")+functionName) {}
104  virtual ~InvalidDepthException() throw() {}
105  };
106 
109  public:
110  InvalidNumChannelException(const std::string &functionName) throw():
111  ICLException(std::string("Invalid number of Channels in: ")+functionName) {}
112  virtual ~InvalidNumChannelException() throw() {}
113  };
114 
117  public:
118  InvalidSizeException(const std::string &functionName) throw():
119  ICLException(std::string("Invalid Size in: ")+functionName) {}
120  virtual ~InvalidSizeException() throw() {}
121  };
122 
124  class ParseException : public ICLException {
125  public:
126  ParseException(const std::string &whatToParse) throw():
127  ICLException(std::string("unable to parse: ")+whatToParse) {}
128  ParseException(const std::string &function, const std::string &line, const std::string &hint="") throw():
129  ICLException("Parsing error in: "+function+" line:"+line + hint){}
130  virtual ~ParseException() throw() {}
131  };
132 
135  public:
136  InvalidRegularExpressionException(const std::string &regex) throw():
137  ICLException("invalid regular expression: '"+regex+"'"){
138  }
140  };
141 
142  #define ICL_FILE_LOCATION (std::string(__FUNCTION__) + "(" + __FILE__ + ")")
143  #define ICL_INVALID_FORMAT throw InvalidFormatException(ICL_FILE_LOCATION)
144  #define ICL_INVALID_DEPTH throw InvalidDepthException(ICL_FILE_LOCATION)
145 
146  } // namespace utils
147 }
148 
InvalidFileFormatException()
Definition: Exception.h:52
undocument this line if you encounter any issues!
Definition: Any.h:37
Function< R, A, B, C > function(Object &obj, R(Object::*method)(A, B, C))
Create Function instances from member functions.
Definition: Function.h:376
Exception thrown if a file could not be read properly.
Definition: Exception.h:76
InvalidRegularExpressionException(const std::string &regex)
Definition: Exception.h:136
FileOpenException(const std::string &sFileName)
Definition: Exception.h:62
InvalidSizeException(const std::string &functionName)
Definition: Exception.h:118
virtual ~FileOpenException()
Definition: Exception.h:64
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
Exception thrown if a function should process an unsupported image depth.
Definition: Exception.h:100
virtual ~InvalidSizeException()
Definition: Exception.h:120
virtual ~InvalidDepthException()
Definition: Exception.h:104
Exception thrown if a string is parsed into a specific type (or something)
Definition: Exception.h:124
InvalidFileException(const std::string &sFileName)
Definition: Exception.h:78
ICLQt_API void line(ImgQ &image, int x1, int y1, int x2, int y2)
draws a line into an image
ICLException(const std::string &msg)
Definition: Exception.h:45
InvalidNumChannelException(const std::string &functionName)
Definition: Exception.h:110
virtual ~InvalidRegularExpressionException()
Definition: Exception.h:139
virtual ~InvalidFormatException()
Definition: Exception.h:96
format
determines the color-format, that is associated with the images channels
Definition: Types.h:70
virtual ~FileNotFoundException()
Definition: Exception.h:72
InvalidFormatException(const std::string &functionName)
Definition: Exception.h:94
InvalidDepthException(const std::string &functionName)
Definition: Exception.h:102
ICLUtils_API void report()
Exception for invalid file formats.
Definition: Exception.h:50
virtual ~InvalidNumChannelException()
Definition: Exception.h:112
virtual ~InvalidFileFormatException()
Definition: Exception.h:56
Exception thrown if a file could not be found.
Definition: Exception.h:68
ICLCV_API void error(const char *msg)
Display error message and terminate program.
Thrown by iclStringUtils::match if regular Expression is not valid.
Definition: Exception.h:134
Exception thrown if a file could not be opend.
Definition: Exception.h:60
FileNotFoundException(const std::string &sFileName)
Definition: Exception.h:70
virtual ~InvalidFileException()
Definition: Exception.h:80
Base class for Exception handling in the ICL.
Definition: Exception.h:42
Exception thrown if a function should process an unsupported image depth.
Definition: Exception.h:108
Exception called if an image gets invalid params.
Definition: Exception.h:84
ParseException(const std::string &whatToParse)
Definition: Exception.h:126
Exception thrown if a function should process an unsupported sizes (e.g. with negative dim....
Definition: Exception.h:116
InvalidImgParamException(const std::string &param)
Definition: Exception.h:86
ParseException(const std::string &function, const std::string &line, const std::string &hint="")
Definition: Exception.h:128
virtual ~ParseException()
Definition: Exception.h:130
Exception thrown if a function should process an unsupported image format.
Definition: Exception.h:92
InvalidFileFormatException(const std::string &hint)
Definition: Exception.h:54
virtual ~InvalidImgParamException()
Definition: Exception.h:88