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.LGPL **
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 <ICLUtils/CompatMacros.h>
00034 #include <iostream>
00035 #include <exception>
00036 #include <string>
00037 #include <stdexcept>
00038 
00039 namespace icl {
00040   namespace utils{
00042     class ICLException : public std::runtime_error
00043     {
00044     public:
00045       ICLException(const std::string &msg) throw() : runtime_error(msg){}
00046       ICLUtils_API void report();
00047     };
00048   
00050     class InvalidFileFormatException : public ICLException {
00051     public:
00052       InvalidFileFormatException () throw() : 
00053          ICLException ("invalid file format") {}
00054          InvalidFileFormatException (const std::string &hint) throw() : 
00055          ICLException ("invalid file format :(" + hint + ")") {}
00056       virtual ~InvalidFileFormatException() throw() {}
00057     };
00058   
00060     class FileOpenException : public ICLException {
00061     public:
00062       FileOpenException (const std::string& sFileName) throw() : 
00063          ICLException (std::string("Can't open file: ") + sFileName) {}
00064       virtual ~FileOpenException() throw() {}
00065     };
00066     
00068     class FileNotFoundException : public ICLException {
00069       public:
00070       FileNotFoundException (const std::string& sFileName) throw() : 
00071       ICLException (std::string("File not found: ") + sFileName) {}
00072       virtual ~FileNotFoundException() throw() {}
00073     };
00074      
00076     class InvalidFileException : public ICLException {
00077       public:
00078       InvalidFileException (const std::string& sFileName) throw() : 
00079       ICLException (std::string("Invalied file: ") + sFileName) {}
00080       virtual ~InvalidFileException() throw() {}
00081     };
00082     
00084     class InvalidImgParamException : public ICLException {
00085       public:
00086       InvalidImgParamException(const std::string &param) throw():
00087         ICLException(std::string("Invalid Img-Parameter: ")+param) {}
00088       virtual ~InvalidImgParamException() throw() {}
00089     };
00090   
00092     class InvalidFormatException : public ICLException {
00093       public:
00094       InvalidFormatException(const std::string &functionName) throw():
00095         ICLException(std::string("Invalid Format in: ")+functionName) {}
00096       virtual ~InvalidFormatException() throw() {}
00097     };
00098   
00100     class InvalidDepthException : public ICLException {
00101       public:
00102       InvalidDepthException(const std::string &functionName) throw():
00103         ICLException(std::string("Invalid Depth in: ")+functionName) {}
00104       virtual ~InvalidDepthException() throw() {}
00105     };
00106    
00108     class InvalidSizeException : public ICLException {
00109       public:
00110       InvalidSizeException(const std::string &functionName) throw():
00111         ICLException(std::string("Invalid Size in: ")+functionName) {}
00112       virtual ~InvalidSizeException() throw() {}
00113     };
00114   
00116     class ParseException : public ICLException {
00117       public:
00118       ParseException(const std::string &whatToParse) throw():
00119         ICLException(std::string("unable to parse: ")+whatToParse) {}
00120       ParseException(const std::string &function, const std::string &line, const std::string &hint="") throw():
00121         ICLException("Parsing error in: "+function+" line:"+line + hint){}
00122       virtual ~ParseException() throw() {}
00123     };
00124     
00126     class InvalidRegularExpressionException : public ICLException{
00127       public:
00128       InvalidRegularExpressionException(const std::string &regex) throw():
00129       ICLException("invalid regular expression: '"+regex+"'"){
00130       }
00131       virtual ~InvalidRegularExpressionException() throw(){}
00132     };
00133   
00134   #define ICL_FILE_LOCATION  (std::string(__FUNCTION__) + "(" + __FILE__ + ")")
00135   #define ICL_INVALID_FORMAT throw InvalidFormatException(ICL_FILE_LOCATION)
00136   #define ICL_INVALID_DEPTH  throw InvalidDepthException(ICL_FILE_LOCATION)
00137   
00138   } // namespace utils
00139 }
00140 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines