Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
clfException.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003, 2004 (see file CONTACTS for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef OPENCLEXCEPTION_HH_
26 #define OPENCLEXCEPTION_HH_
27 
28 #include <bias_config.h>
29 #include <Base/Common/BIASpragmaStart.hh>
30 #include <OpenCLFramework/clfOpenCL.hh>
31 #include <exception>
32 
33 namespace BIAS {
34 
35 #define THROW_CL_EXCEPTION(err) \
36  throw clfException(err, __FILE__, __LINE__)
37 
38  /**
39  *
40  * @brief clf Exception wrapper, is thrown in case of most clf errors
41  *
42  * clf Exceptions are enabled in this library. This class wraps these
43  * exceptions and add more information. Almost all functions in the library
44  * throw an exception instead of returning error codes, so catch them!
45  *
46  * @author fkellner 06/11
47  */
48  class BIASOpenCLFramework_EXPORT clfException : public std::exception {
49  public:
50  /// @brief is called by THROW_CL_EXCEPTION macro
51  clfException(cl::Error clerror, std::string file, int line) throw();
52 
53  virtual ~clfException() throw() {}
54 
55  /// @brief file in which error occured
56  const std::string& GetFileName() const throw();
57  /// @brief line in which error occured
58  int GetLineNumber() const throw();
59  /// @brief clf error code
60  int GetErrorCode() const throw();
61  /// @brief clf error message (usually name of failing c function)
62  const std::string& GetMessageString() const throw();
63  /// @brief clf translated error code (todo clean up text)
64  const std::string& GetReasonString() const throw();
65  /// @brief detailed combination of all info available
66  const std::string& GetDetailedString() const throw();
67 
68  virtual const char* what() const throw();
69 
70  private:
71  std::string fileName_;
72  int lineNumber_;
73  std::string message_;
74  int errorCode_;
75  std::string reason_;
76  std::string detailed_;
77 
78  };
79 
80 }
81 #include <Base/Common/BIASpragmaEnd.hh>
82 #endif /* clfEXCEPTION_HH_ */
clf Exception wrapper, is thrown in case of most clf errors
Definition: clfException.hh:48
virtual ~clfException()
Definition: clfException.hh:53