HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Exception.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_EXCEPTION_H
7 #define MATERIALX_EXCEPTION_H
8 
9 #include <MaterialXCore/Export.h>
10 
11 #include <exception>
12 
13 /// @file
14 /// Base exception classes
15 
17 
18 /// @class Exception
19 /// The base class for exceptions that are propagated from the MaterialX library
20 /// to the client application.
21 class MX_CORE_API Exception : public std::exception
22 {
23  public:
24  explicit Exception(const string& msg) :
25  _msg(msg)
26  {
27  }
28 
29  Exception(const Exception& e) :
30  _msg(e._msg)
31  {
32  }
33 
35  {
36  _msg = e._msg;
37  return *this;
38  }
39 
40  virtual ~Exception() noexcept
41  {
42  }
43 
44  const char* what() const noexcept override
45  {
46  return _msg.c_str();
47  }
48 
49  private:
50  string _msg;
51 };
52 
54 
55 #endif
virtual ~Exception() noexcept
Definition: Exception.h:40
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
#define MX_CORE_API
Definition: Export.h:18
Exception & operator=(const Exception &e)
Definition: Exception.h:34
Exception(const Exception &e)
Definition: Exception.h:29
const char * what() const noexceptoverride
Definition: Exception.h:44
Exception(const string &msg)
Definition: Exception.h:24
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26