Cortex  10.0.0-a4
Exception.h
1 //
3 // Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IE_CORE_EXCEPTION_H
36 #define IE_CORE_EXCEPTION_H
37 
38 #include <string>
39 #include <exception>
40 
41 #include "RefCounted.h"
42 
43 #include "IECore/Export.h"
44 
45 namespace IECore
46 {
49  class IECORE_API Exception : public std::exception
50  {
51  public:
53  Exception(const char *what);
54  Exception(const std::string &what);
55 
56  ~Exception() throw () override;
57 
58  // Return type of exception
59  virtual const char *type() const throw();
60 
62  const char* what() const throw() override;
63 
65  Exception &append( const std::string &s );
66 
68  Exception &append( const char *s );
69 
71  Exception &prepend( const std::string &s );
72 
74  Exception &prepend( const char *s );
75 
76  protected:
77 
78  class RefCountedString : public RefCounted, public std::string
79  {
80  public:
81  RefCountedString(const char * s) : std::string(s) {}
82  RefCountedString(const std::string &s) : std::string(s) {}
83  };
84 
85  IE_CORE_DECLAREPTR( RefCountedString )
86 
87  RefCountedStringPtr m_what;
88  };
89 
91  class IECORE_API IOException : public Exception
92  {
93  public:
94  IOException(const char *what) : Exception(what) {};
95  IOException(const std::string &what) : Exception(what) {};
96 
97  const char *type() const throw() override { return "I/O Exception"; }
98  };
99 
101  class IECORE_API FileNotFoundIOException : public IOException
102  {
103  public:
104  FileNotFoundIOException(const char *what) : IOException(what) {};
105  FileNotFoundIOException(const std::string &what) : IOException(what) {};
106 
107  const char *type() const throw() override { return "File Not Found"; }
108  };
109 
111  class IECORE_API InvalidArgumentException : public Exception
112  {
113  public:
114  InvalidArgumentException(const char *what) : Exception(what) {};
115  InvalidArgumentException(const std::string &what) : Exception(what) {};
116 
117  const char *type() const throw() override { return "Invalid Argument"; }
118  };
119 
121  class IECORE_API PermissionDeniedIOException : public IOException
122  {
123  public:
124  PermissionDeniedIOException(const char *what) : IOException(what) {};
125  PermissionDeniedIOException(const std::string &what) : IOException(what) {};
126 
127  const char *type() const throw() override { return "Permission Denied"; }
128  };
129 
131  class IECORE_API NotImplementedException : public Exception
132  {
133  public:
134  NotImplementedException(const char *what) : Exception(what) {};
135  NotImplementedException(const std::string &what) : Exception(what) {};
136 
137  const char *type() const throw() override { return "Not Implemented"; }
138  };
139 }
140 
141 #endif // IE_CORE_EXCEPTION_H
A class to represent "not implemented" exceptions.
Definition: Exception.h:131
Definition: Exception.h:49
Base class for Invalid Argument exceptions.
Definition: Exception.h:111
A class to represent "file not found" exceptions.
Definition: Exception.h:101
A class to represent "permission denied" exceptions.
Definition: Exception.h:121
Definition: RefCounted.h:124
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43
Base class for Input/Output exceptions.
Definition: Exception.h:91