00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "precomp.h"
00030 #include "dom_exception.h"
00031 #include "string_format.h"
00032
00034
00035
00036 static std::string code_to_message(unsigned short code)
00037 {
00038 switch (code)
00039 {
00040 case CL_DomException::DOMSTRING_SIZE_ERR:
00041 return "DOMSTRING_SIZE_ERR: Specified range of text does not fit into a DOMString";
00042
00043 case CL_DomException::HIERARCHY_REQUEST_ERR:
00044 return "HIERARCHY_REQUEST_ERR: Attemped to insert node where it doesn't belong";
00045
00046 case CL_DomException::INDEX_SIZE_ERR:
00047 return "INDEX_SIZE_ERR: Index or size is negative, or greater than the allowed value";
00048
00049 case CL_DomException::INUSE_ATTRIBUTE_ERR:
00050 return "INUSE_ATTRIBUTE_ERR: An attempt was made to add an attribute that is already in use elsewhere";
00051
00052 case CL_DomException::INVALID_CHARACTER_ERR:
00053 return "INVALID_CHARACTER_ERR: An invalid or illegal character was specified, such as in a name";
00054
00055 case CL_DomException::NOT_FOUND_ERR:
00056 return "NOT_FOUND_ERR: An attempt was made to reference a node in a context where it does not exist";
00057
00058 case CL_DomException::NOT_SUPPORTED_ERR:
00059 return "NOT_SUPPORTED_ERR: The implementation does not support the type of object requested";
00060
00061 case CL_DomException::NO_DATA_ALLOWED_ERR:
00062 return "NO_DATA_ALLOWED_ERR: Data was specified for a node which does not support data";
00063
00064 case CL_DomException::NO_MODIFICATION_ALLOWED_ERR:
00065 return "NO_MODIFICATION_ALLOWED_ERR: An attempt was made to modify an object where modifications are not allowed";
00066
00067 case CL_DomException::WRONG_DOCUMENT_ERR:
00068 return "WRONG_DOCUMENT_ERR: A node was used in a different document than the one that created it";
00069 }
00070
00071 CL_StringFormat format("Unknown DOM exception code %1");
00072 format.set_arg(1, code);
00073 return format.get_result();
00074 }
00075
00076 CL_DomException::CL_DomException(unsigned short code) : CL_Exception(code_to_message(code)), code(code)
00077 {
00078 }
00079
00080 CL_DomException::CL_DomException(const std::string &message, unsigned short code) : CL_Exception(message), code(code)
00081 {
00082 }
00083
00085
00086
00088