| 23 | namespace sonic_json { |
| 24 | |
| 25 | enum SonicError { |
| 26 | kErrorNone = 0, ///< No errors. |
| 27 | kParseErrorEof = 1, ///< Parse: JSON is empty or truncated. |
| 28 | kParseErrorInvalidChar = 2, ///< Parse: JSON has invalid chars, e.g. 1.2x. |
| 29 | kParseErrorInfinity = 3, ///< Parse: JSON number is infinity. |
| 30 | kParseErrorUnEscaped = 4, ///< Parse: JSON string has unescaped control chars |
| 31 | ///< (\x00 ~ \x1f) |
| 32 | kParseErrorEscapedFormat = 5, ///< Parse: JSON string has wrong escaped |
| 33 | ///< format, e.g. |
| 34 | ///< "\\g" |
| 35 | kParseErrorEscapedUnicode = 6, ///< Parse: JSON string has wrong escaped |
| 36 | ///< unicode, e.g. |
| 37 | ///< "\\uD800" |
| 38 | kParseErrorInvalidUTF8 = 7, ///< Parse: JSON string has wrong escaped |
| 39 | ///< unicode, e.g. |
| 40 | ///< "\xff\xff" |
| 41 | kParseErrorUnknownObjKey = 8, ///< ParseOnDemand: Not found the target keys |
| 42 | ///< in object. |
| 43 | kParseErrorArrIndexOutOfRange = 9, ///< ParseOnDemand: the target array index |
| 44 | ///< out of range. |
| 45 | kParseErrorMismatchType = |
| 46 | 10, ///< ParseOnDemand: the target type is not matched. |
| 47 | kSerErrorUnsupportedType = 11, ///< Serialize: DOM has invalid node type. |
| 48 | kSerErrorInfinity = 12, ///< Serialize: DOM has inifinity number node. |
| 49 | kSerErrorInvalidObjKey = 13, ///< Serialize: The type of object's key is not |
| 50 | ///< string. |
| 51 | kErrorNoMem = 14, ///< Memory is not enough to allocate. |
| 52 | kParseErrorUnexpect = 15, ///< Unexpected Errors |
| 53 | |
| 54 | kErrorNums, |
| 55 | }; |
| 56 | |
| 57 | inline const char* ErrorMsg(SonicError error) noexcept { |
| 58 | struct SonicErrorInfo { |
no outgoing calls
no test coverage detected