Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Exception.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLUtils/src/ICLUtils/Exception.h                      **
00010 ** Module : ICLUtils                                               **
00011 ** Authors: Christof Elbrechter, Michael Goetting, Robert Haschke  **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.GPL  **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <iostream>
00034 #include <exception>
00035 #include <string>
00036 #include <stdexcept>
00037 
00038 namespace icl {
00039   namespace utils{
00041     class ICLException : public std::runtime_error
00042     {
00043     public:
00044       ICLException (const std::string &msg) throw() : runtime_error(msg){}
00045       void report();
00046     };
00047   
00049     class InvalidFileFormatException : public ICLException {
00050     public:
00051       InvalidFileFormatException () throw() : 
00052          ICLException ("invalid file format") {}
00053          InvalidFileFormatException (const std::string &hint) throw() : 
00054          ICLException ("invalid file format :(" + hint + ")") {}
00055       virtual ~InvalidFileFormatException() throw() {}
00056     };
00057   
00059     class FileOpenException : public ICLException {
00060     public:
00061       FileOpenException (const std::string& sFileName) throw() : 
00062          ICLException (std::string("Can't open file: ") + sFileName) {}
00063       virtual ~FileOpenException() throw() {}
00064     };
00065     
00067     class FileNotFoundException : public ICLException {
00068       public:
00069       FileNotFoundException (const std::string& sFileName) throw() : 
00070       ICLException (std::string("File not found: ") + sFileName) {}
00071       virtual ~FileNotFoundException() throw() {}
00072     };
00073      
00075     class InvalidFileException : public ICLException {
00076       public:
00077       InvalidFileException (const std::string& sFileName) throw() : 
00078       ICLException (std::string("Invalied file: ") + sFileName) {}
00079       virtual ~InvalidFileException() throw() {}
00080     };
00081     
00083     class InvalidImgParamException : public ICLException {
00084       public:
00085       InvalidImgParamException(const std::string &param) throw():
00086         ICLException(std::string("Invalid Img-Parameter: ")+param) {}
00087       virtual ~InvalidImgParamException() throw() {}
00088     };
00089   
00091     class InvalidFormatException : public ICLException {
00092       public:
00093       InvalidFormatException(const std::string &functionName) throw():
00094         ICLException(std::string("Invalid Format in: ")+functionName) {}
00095       virtual ~InvalidFormatException() throw() {}
00096     };
00097   
00099     class InvalidDepthException : public ICLException {
00100       public:
00101       InvalidDepthException(const std::string &functionName) throw():
00102         ICLException(std::string("Invalid Depth in: ")+functionName) {}
00103       virtual ~InvalidDepthException() throw() {}
00104     };
00105    
00107     class InvalidSizeException : public ICLException {
00108       public:
00109       InvalidSizeException(const std::string &functionName) throw():
00110         ICLException(std::string("Invalid Size in: ")+functionName) {}
00111       virtual ~InvalidSizeException() throw() {}
00112     };
00113   
00115     class ParseException : public ICLException {
00116       public:
00117       ParseException(const std::string &whatToParse) throw():
00118         ICLException(std::string("unable to parse: ")+whatToParse) {}
00119       ParseException(const std::string &function, const std::string &line, const std::string &hint="") throw():
00120         ICLException("Parsing error in: "+function+" line:"+line + hint){}
00121       virtual ~ParseException() throw() {}
00122     };
00123     
00125     class InvalidRegularExpressionException : public ICLException{
00126       public:
00127       InvalidRegularExpressionException(const std::string &regex) throw():
00128       ICLException("invalid regular expression: '"+regex+"'"){
00129       }
00130       virtual ~InvalidRegularExpressionException() throw(){}
00131     };
00132   
00133   #define ICL_FILE_LOCATION  (std::string(__FUNCTION__) + "(" + __FILE__ + ")")
00134   #define ICL_INVALID_FORMAT throw InvalidFormatException(ICL_FILE_LOCATION)
00135   #define ICL_INVALID_DEPTH  throw InvalidDepthException(ICL_FILE_LOCATION)
00136   
00137   } // namespace utils
00138 }
00139 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines