blob: 55f389ed53801d97b9f43735c21467df78e52603 [file] [log] [blame]
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +01001/*==============================================================================
2 err_to_str.c -- strings names for errors
3
4 Copyright (c) 2020, Patrick Uiterwijk. All rights reserved.
Laurence Lundblade5f3aa812020-10-06 11:20:38 -07005 Copyright (c) 2020, Laurence Lundblade.
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +01006
7 SPDX-License-Identifier: BSD-3-Clause
8
9 See BSD-3-Clause license in README.md
10
11 Created on 3/21/20
12 =============================================================================*/
13
Laurence Lundblade9c905e82020-04-25 11:31:38 -070014#include "qcbor/qcbor_common.h"
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010015
16#define _ERR_TO_STR(errpart) case QCBOR_##errpart: return "QCBOR_" #errpart;
17
18const char *qcbor_err_to_str(QCBORError err) {
19 switch (err) {
20 _ERR_TO_STR(SUCCESS)
21 _ERR_TO_STR(ERR_BUFFER_TOO_SMALL)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070022 _ERR_TO_STR(ERR_ENCODE_UNSUPPORTED)
23 _ERR_TO_STR(ERR_BUFFER_TOO_LARGE)
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010024 _ERR_TO_STR(ERR_ARRAY_NESTING_TOO_DEEP)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070025 _ERR_TO_STR(ERR_CLOSE_MISMATCH)
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010026 _ERR_TO_STR(ERR_ARRAY_TOO_LONG)
27 _ERR_TO_STR(ERR_TOO_MANY_CLOSES)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070028 _ERR_TO_STR(ERR_ARRAY_OR_MAP_STILL_OPEN)
29 _ERR_TO_STR(ERR_BAD_TYPE_7)
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010030 _ERR_TO_STR(ERR_EXTRA_BYTES)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070031 _ERR_TO_STR(ERR_UNSUPPORTED)
32 _ERR_TO_STR(ERR_ARRAY_OR_MAP_UNCONSUMED)
33 _ERR_TO_STR(ERR_BAD_INT)
34 _ERR_TO_STR(ERR_INDEFINITE_STRING_CHUNK)
35 _ERR_TO_STR(ERR_HIT_END)
36 _ERR_TO_STR(ERR_BAD_BREAK)
37 _ERR_TO_STR(ERR_INPUT_TOO_LARGE)
38 _ERR_TO_STR(ERR_ARRAY_DECODE_NESTING_TOO_DEEP)
39 _ERR_TO_STR(ERR_ARRAY_DECODE_TOO_LONG)
40 _ERR_TO_STR(ERR_STRING_TOO_LONG)
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010041 _ERR_TO_STR(ERR_BAD_EXP_AND_MANTISSA)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070042 _ERR_TO_STR(ERR_NO_STRING_ALLOCATOR)
43 _ERR_TO_STR(ERR_STRING_ALLOCATE)
44 _ERR_TO_STR(ERR_TOO_MANY_TAGS)
45 _ERR_TO_STR(ERR_MAP_LABEL_TYPE)
46 _ERR_TO_STR(ERR_UNEXPECTED_TYPE)
47 _ERR_TO_STR(ERR_BAD_OPT_TAG)
48 _ERR_TO_STR(ERR_DUPLICATE_LABEL)
49 _ERR_TO_STR(ERR_MEM_POOL_SIZE)
50 _ERR_TO_STR(ERR_INT_OVERFLOW)
51 _ERR_TO_STR(ERR_DATE_OVERFLOW)
52 _ERR_TO_STR(ERR_EXIT_MISMATCH)
53 _ERR_TO_STR(ERR_NO_MORE_ITEMS)
54 _ERR_TO_STR(ERR_LABEL_NOT_FOUND)
55 _ERR_TO_STR(ERR_NUMBER_SIGN_CONVERSION)
56 _ERR_TO_STR(ERR_CONVERSION_UNDER_OVER_FLOW)
57 _ERR_TO_STR(ERR_MAP_NOT_ENTERED)
58 _ERR_TO_STR(ERR_CALLBACK_FAIL)
59 _ERR_TO_STR(ERR_FLOAT_DATE_DISABLED)
60 _ERR_TO_STR(ERR_HALF_PRECISION_DISABLED)
61 _ERR_TO_STR(ERR_HW_FLOAT_DISABLED)
62 _ERR_TO_STR(ERR_FLOAT_EXCEPTION)
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010063
64 default:
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070065 return "Unidentified error";
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010066 }
67}