20 #ifndef _SAIEXCEPTION_H_
21 #define _SAIEXCEPTION_H_
23 #define SAI_GENERIC_EXCEPTION 0
24 #define SAI_BROWSER_UNAVAILABLE 1
25 #define SAI_CONNECTION_ERROR 2
26 #define SAI_DISPOSED 3
27 #define SAI_IMPORTED_NODE 4
28 #define SAI_INSUFFICIENT_CAPABILITIES 5
29 #define SAI_INVALID_ACCESS_TYPE 6
30 #define SAI_INVALID_BROWSER 7
31 #define SAI_INVALID_DOCUMENT 8
32 #define SAI_INVALID_FIELD 9
33 #define SAI_INVALID_NAME 10 //mapped to SAI_INVALID_FIELD or to SAI_INVALID_NODE as Java Language Binding does
34 #define SAI_INVALID_NODE 11
35 #define SAI_INVALID_OPERATION_TIMING 12
36 #define SAI_INVALID_URL 13
37 #define SAI_INVALID_X3D 14
38 #define SAI_NODE_NOT_AVAILABLE 15
39 #define SAI_NODE_IN_USE 16
40 #define SAI_NOT_SHARED 17
41 #define SAI_NOT_SUPPORTED 18
42 #define SAI_URL_UNAVAILABLE 19
43 #define SAI_INVALID_EXECUTION_CONTEXT 20
45 #define SAI_NOT_READABLE_FIELD 21
46 #define SAI_NOT_WRITABLE_FIELD 22
49 #define SAI_CUSTOM_EXCEPTION 100
53 namespace freeWRLSAI_cpp
64 virtual const char* what(){
return "Generic SAI exception.\n";}
66 virtual int GetError(){
return m_nErrorCode;}
78 m_nErrorCode = SAI_BROWSER_UNAVAILABLE;
81 virtual const char* what(){
return "The request to gain a reference to a SAIBrowserApp has failed.\n "
82 "The connection may be down or the type of reference required is not supported.";}
90 m_nErrorCode = SAI_CONNECTION_ERROR;
93 virtual const char* what(){
return "Connection to browser failed or was never established.\n";}
101 m_nErrorCode = SAI_DISPOSED;
104 virtual const char* what(){
return "The reference required has already beed disposed in this context.\n";}
112 m_nErrorCode = SAI_IMPORTED_NODE;
115 virtual const char* what(){
return "An operation was attempted that used an imported node when it is not permitted.\n";}
123 m_nErrorCode = SAI_INSUFFICIENT_CAPABILITIES;
126 virtual const char* what(){
return "Cannot add a node to an execution context that is greater than the capabilities defined by the profile and components definition for the scene.\n";}
134 m_nErrorCode = SAI_INVALID_ACCESS_TYPE;
137 virtual const char* what(){
return "Cannot perform the requested operation because it is an invalid action for this field type.\n";}
145 m_nErrorCode = SAI_INVALID_BROWSER;
148 virtual const char* what(){
return "The Browser service requested has been disposed of prior to this request.\n";}
156 m_nErrorCode = SAI_INVALID_DOCUMENT;
159 virtual const char* what(){
return "The document structure is not compliant with X3D DOM.\n";}
167 m_nErrorCode = SAI_INVALID_OPERATION_TIMING;
170 virtual const char* what(){
return "The user is attempting to make a service request that is performed outside of the context that such operations are permitted in.\n";}
178 m_nErrorCode = SAI_INVALID_URL;
181 virtual const char* what(){
return "Syntax Error: the url specified is not correct.\n";}
189 m_nErrorCode = SAI_INVALID_X3D;
192 virtual const char* what(){
return "Syntax Error: the X3D document requested or specified is not correct.\n";}
200 m_nErrorCode = SAI_NODE_NOT_AVAILABLE;
203 virtual const char* what(){
return "The imported node requested has not yet been verified for export.\n";}
211 m_nErrorCode = SAI_NODE_IN_USE;
214 virtual const char* what(){
return "A named node handling action has attempted to re-use a name that is already defined elsewhere in this current scene.\n "
215 "Or the node, or one of its children, is currently in use in another scene.\n";}
223 m_nErrorCode = SAI_NOT_SHARED;
226 virtual const char* what(){
return "A service request was made that assumed the browser was currently participating in a shared scene graph when it was not.\n";}
234 m_nErrorCode = SAI_NOT_SUPPORTED;
237 virtual const char* what(){
return "The service request is not supported.\n";}
245 m_nErrorCode = SAI_URL_UNAVAILABLE;
248 virtual const char* what(){
return "No valid URL has been specified for this request.\n";}
258 m_nErrorCode = SAI_INVALID_EXECUTION_CONTEXT;
261 virtual const char* what(){
return "The execution context requested has been disposed of prior to this request.\n";}
269 m_nErrorCode = SAI_INVALID_FIELD;
272 virtual const char* what(){
return "The requested field has been disposed of prior to this request.\n";}
280 m_nErrorCode = SAI_INVALID_NODE;
283 virtual const char* what(){
return "The requested node has been disposed of prior to this request.\n";}
292 invalidFieldException::m_nErrorCode = SAI_NOT_WRITABLE_FIELD;
295 virtual const char* what(){
return "The requested field cannot be written.\n";}
303 invalidFieldException::m_nErrorCode = SAI_NOT_READABLE_FIELD;
306 virtual const char* what(){
return "The requested field cannot be read.\n";}
313 saiCustomException(
const char* strWhat,
const char* strFile,
int strLine,
const char* strFunc)
315 m_nErrorCode = SAI_CUSTOM_EXCEPTION;
319 int nChars = sprintf_s(buffer,256,
"%s\n In file: %s, line: %d, function: %s",strWhat,strFile,strLine,strFunc);
324 m_strWhat =
"Exception message was not well formed.\n";
327 virtual const char* what(){
return m_strWhat.c_str();}
329 std::string m_strWhat;
334 #endif //_SAIEXCEPTION_H_