00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __HOM_Errors_h__
00017 #define __HOM_Errors_h__
00018
00019 #include "HOM_API.h"
00020 #include "HOM_Defines.h"
00021 #include <string>
00022
00023
00024
00025
00026
00027 SWIGOUT(%rename(SystemExit) HOM_SystemExit;)
00028 class HOM_API HOM_SystemExit
00029 {
00030 public:
00031 HOM_SystemExit(int exit_code)
00032 : myExitCode(exit_code)
00033 {}
00034
00035 int code()
00036 { return myExitCode; }
00037
00038 private:
00039 int myExitCode;
00040 };
00041
00042
00043
00044
00045
00046 SWIGOUT(%rename(Error) HOM_Error;)
00047 class HOM_API HOM_Error
00048 {
00049 public:
00050 HOM_Error(const char *instance_message = "")
00051 : myInstanceMessage(instance_message ? instance_message : "")
00052 {}
00053
00054 virtual ~HOM_Error()
00055 {}
00056
00057 virtual std::string exceptionTypeName() { return "Error"; }
00058
00059 virtual std::string description() { return ""; }
00060
00061 virtual std::string instanceMessage() { return myInstanceMessage; }
00062
00063 std::string __repr__()
00064 {
00065 std::string result = "<hou.";
00066 result += exceptionTypeName();
00067 result += ">";
00068 return result;
00069 }
00070
00071 std::string __str__()
00072 {
00073 std::string result;
00074 if (description().size())
00075 {
00076 result += description();
00077 result += ".";
00078 }
00079 std::string instance_msg = instanceMessage();
00080 if (instance_msg.size())
00081 {
00082 if (description().size())
00083 result += "\n";
00084 result += instance_msg;
00085 }
00086 return result;
00087 }
00088
00089 private:
00090 std::string myInstanceMessage;
00091 };
00092
00093
00094
00095
00096 #define SIMPLE_EXCEPTION(exception_name, description_value) \
00097 SWIGOUT(%rename(exception_name) HOM_ ## exception_name;) \
00098 class HOM_API HOM_ ## exception_name : public HOM_Error \
00099 { \
00100 public: \
00101 HOM_ ## exception_name(const char* instance_message = "") \
00102 : HOM_Error(instance_message) \
00103 {} \
00104 virtual std::string exceptionTypeName() { return #exception_name; } \
00105 virtual std::string description() { return description_value; } \
00106 SWIGOUT(std::string __repr__();) \
00107 SWIGOUT(std::string __str__();) \
00108 };
00109
00110 #define SIMPLE_EXCEPTION_DFLT_INSTANCE(exception_name, description_value, \
00111 default_instance_value) \
00112 SWIGOUT(%rename(exception_name) HOM_ ## exception_name;) \
00113 class HOM_API HOM_ ## exception_name : public HOM_Error \
00114 { \
00115 public: \
00116 HOM_ ## exception_name(const char* instance_message = "") \
00117 : HOM_Error(instance_message) \
00118 {} \
00119 virtual std::string exceptionTypeName() { return #exception_name; } \
00120 virtual std::string description() { return description_value; } \
00121 virtual std::string instanceMessage() \
00122 { \
00123 std::string instance_msg = HOM_Error::instanceMessage(); \
00124 if (!instance_msg.size()) instance_msg = default_instance_value; \
00125 return instance_msg; \
00126 } \
00127 SWIGOUT(std::string __repr__();) \
00128 SWIGOUT(std::string __str__();) \
00129 };
00130
00131 SIMPLE_EXCEPTION(NotAvailable,
00132 "Not available in this context")
00133 SIMPLE_EXCEPTION(ObjectWasDeleted,
00134 "Attempt to access an object that no longer exists in Houdini")
00135 SIMPLE_EXCEPTION(InvalidInput,
00136 "Invalid input")
00137 SIMPLE_EXCEPTION(InvalidSize,
00138 "Invalid size")
00139 SIMPLE_EXCEPTION(TypeError,
00140 "Invalid type")
00141 SIMPLE_EXCEPTION(ValueError,
00142 "Invalid value")
00143 SIMPLE_EXCEPTION(OperationFailed,
00144 "The attempted operation failed")
00145 SIMPLE_EXCEPTION(InvalidNodeType,
00146 "The node type is invalid")
00147 SIMPLE_EXCEPTION(InitScriptFailed,
00148 "Node initialization script failed")
00149 SIMPLE_EXCEPTION(MatchDefinitionError,
00150 "Failed to match node type definition")
00151 SIMPLE_EXCEPTION_DFLT_INSTANCE(PermissionError, "",
00152 "Failed to modify node or parameter because of a permission "
00153 "error. Possible causes include locked assets, takes, "
00154 "product permissions or user specified permissions")
00155 SIMPLE_EXCEPTION(GeometryPermissionError,
00156 "Geometry is read-only")
00157 SIMPLE_EXCEPTION(KeyframeValueNotSet,
00158 "This keyframe value is not set")
00159 SIMPLE_EXCEPTION(OperationInterrupted,
00160 "The requested operation was interrupted")
00161 SIMPLE_EXCEPTION(LoadWarning,
00162 "Warnings were generated during load")
00163 SIMPLE_EXCEPTION(NodeError,
00164 "Error generated by Python node")
00165 SIMPLE_EXCEPTION(NodeWarning,
00166 "Warning generated by Python node")
00167
00168 #endif