1 /****************************************************************************
3 ** Copyright (C) 2015 Intel Corporation
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
12 ** The above copyright notice and this permission notice shall be included in
13 ** all copies or substantial portions of the Software.
15 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 ****************************************************************************/
31 const char *cbor_error_string(CborError error)
37 case CborUnknownError:
38 return _("unknown error");
40 case CborErrorOutOfMemory:
41 return _("out of memory/need more memory");
43 case CborErrorUnknownLength:
44 return _("unknown length (attempted to get the length of a map/array/string of indeterminate length");
46 case CborErrorAdvancePastEOF:
47 return _("attempted to advance past EOF");
50 return _("I/O error");
52 case CborErrorGarbageAtEnd:
53 return _("garbage after the end of the content");
55 case CborErrorUnexpectedEOF:
56 return _("unexpected end of data");
58 case CborErrorUnexpectedBreak:
59 return _("unexpected 'break' byte");
61 case CborErrorUnknownType:
62 return _("illegal byte (encodes future extension type)");
64 case CborErrorIllegalType:
65 return _("mismatched string type in chunked string");
67 case CborErrorIllegalNumber:
68 return _("illegal initial byte (encodes unspecified additional information)");
70 case CborErrorIllegalSimpleType:
71 return _("illegal encoding of simple type smaller than 32");
73 case CborErrorUnknownSimpleType:
74 return _("unknown simple type");
76 case CborErrorUnknownTag:
77 return _("unknown tag");
79 case CborErrorInappropriateTagForType:
80 return _("inappropriate tag for type");
82 case CborErrorDuplicateObjectKeys:
83 return _("duplicate keys in object");
85 case CborErrorInvalidUtf8TextString:
86 return _("invalid UTF-8 content in string");
88 case CborErrorTooManyItems:
89 return _("too many items added to encoder");
91 case CborErrorTooFewItems:
92 return _("too few items added to encoder");
94 case CborErrorDataTooLarge:
95 return _("internal error: data too large");
97 case CborErrorNestingTooDeep:
98 return _("internal error: too many nested containers found in recursive function");
100 case CborErrorUnsupportedType:
101 return _("unsupported type");
103 case CborErrorJsonObjectKeyIsAggregate:
104 return _("conversion to JSON failed: key in object is an array or map");
106 case CborErrorJsonObjectKeyNotString:
107 return _("conversion to JSON failed: key in object is not a string");
110 case CborErrorInternalError:
111 return _("internal error");
113 return cbor_error_string(CborUnknownError);