blob: 4879f91d5b60497350a2e0341f97b15c47e8d3c8 [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.
Máté Tóth-Pálef5f07a2021-09-17 19:31:37 +02006 Copyright (c) 2021, Arm Limited. All rights reserved.
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +01007
8 SPDX-License-Identifier: BSD-3-Clause
9
10 See BSD-3-Clause license in README.md
11
12 Created on 3/21/20
13 =============================================================================*/
14
Laurence Lundblade9c905e82020-04-25 11:31:38 -070015#include "qcbor/qcbor_common.h"
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010016
17#define _ERR_TO_STR(errpart) case QCBOR_##errpart: return "QCBOR_" #errpart;
18
19const char *qcbor_err_to_str(QCBORError err) {
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070020 switch (err) {
21 _ERR_TO_STR(SUCCESS)
22 _ERR_TO_STR(ERR_BUFFER_TOO_SMALL)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070023 _ERR_TO_STR(ERR_ENCODE_UNSUPPORTED)
24 _ERR_TO_STR(ERR_BUFFER_TOO_LARGE)
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070025 _ERR_TO_STR(ERR_ARRAY_NESTING_TOO_DEEP)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070026 _ERR_TO_STR(ERR_CLOSE_MISMATCH)
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070027 _ERR_TO_STR(ERR_ARRAY_TOO_LONG)
28 _ERR_TO_STR(ERR_TOO_MANY_CLOSES)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070029 _ERR_TO_STR(ERR_ARRAY_OR_MAP_STILL_OPEN)
30 _ERR_TO_STR(ERR_BAD_TYPE_7)
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070031 _ERR_TO_STR(ERR_EXTRA_BYTES)
32 _ERR_TO_STR(ERR_UNSUPPORTED)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070033 _ERR_TO_STR(ERR_ARRAY_OR_MAP_UNCONSUMED)
34 _ERR_TO_STR(ERR_BAD_INT)
35 _ERR_TO_STR(ERR_INDEFINITE_STRING_CHUNK)
36 _ERR_TO_STR(ERR_HIT_END)
37 _ERR_TO_STR(ERR_BAD_BREAK)
38 _ERR_TO_STR(ERR_INPUT_TOO_LARGE)
39 _ERR_TO_STR(ERR_ARRAY_DECODE_NESTING_TOO_DEEP)
40 _ERR_TO_STR(ERR_ARRAY_DECODE_TOO_LONG)
41 _ERR_TO_STR(ERR_STRING_TOO_LONG)
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070042 _ERR_TO_STR(ERR_BAD_EXP_AND_MANTISSA)
43 _ERR_TO_STR(ERR_NO_STRING_ALLOCATOR)
44 _ERR_TO_STR(ERR_STRING_ALLOCATE)
45 _ERR_TO_STR(ERR_TOO_MANY_TAGS)
46 _ERR_TO_STR(ERR_MAP_LABEL_TYPE)
47 _ERR_TO_STR(ERR_UNEXPECTED_TYPE)
48 _ERR_TO_STR(ERR_BAD_OPT_TAG)
49 _ERR_TO_STR(ERR_DUPLICATE_LABEL)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070050 _ERR_TO_STR(ERR_MEM_POOL_SIZE)
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070051 _ERR_TO_STR(ERR_INT_OVERFLOW)
52 _ERR_TO_STR(ERR_DATE_OVERFLOW)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070053 _ERR_TO_STR(ERR_EXIT_MISMATCH)
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070054 _ERR_TO_STR(ERR_NO_MORE_ITEMS)
Laurence Lundblade5f3aa812020-10-06 11:20:38 -070055 _ERR_TO_STR(ERR_LABEL_NOT_FOUND)
56 _ERR_TO_STR(ERR_NUMBER_SIGN_CONVERSION)
57 _ERR_TO_STR(ERR_CONVERSION_UNDER_OVER_FLOW)
58 _ERR_TO_STR(ERR_MAP_NOT_ENTERED)
59 _ERR_TO_STR(ERR_CALLBACK_FAIL)
60 _ERR_TO_STR(ERR_FLOAT_DATE_DISABLED)
61 _ERR_TO_STR(ERR_HALF_PRECISION_DISABLED)
62 _ERR_TO_STR(ERR_HW_FLOAT_DISABLED)
63 _ERR_TO_STR(ERR_FLOAT_EXCEPTION)
Máté Tóth-Pálef5f07a2021-09-17 19:31:37 +020064 _ERR_TO_STR(ERR_ALL_FLOAT_DISABLED)
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010065
Laurence Lundbladeb2fd03c2020-10-07 09:54:14 -070066 default:
67 return "Unidentified error";
68 }
Patrick Uiterwijk84c7f7e2020-03-21 19:00:05 +010069}