• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2021, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * @file
31  *   This file defines the errors used by OpenThread core.
32  */
33 
34 #ifndef ERROR_HPP_
35 #define ERROR_HPP_
36 
37 #include "openthread-core-config.h"
38 
39 #include <openthread/error.h>
40 
41 #include <stdint.h>
42 
43 namespace ot {
44 
45 /**
46  * Represents error codes used by OpenThread core modules.
47  */
48 typedef otError Error;
49 
50 /*
51  * The `OT_ERROR_*` enumeration values are re-defined using `kError` style format.
52  * See `openthread/error.h` for more details about each error.
53  */
54 constexpr Error kErrorNone                       = OT_ERROR_NONE;
55 constexpr Error kErrorFailed                     = OT_ERROR_FAILED;
56 constexpr Error kErrorDrop                       = OT_ERROR_DROP;
57 constexpr Error kErrorNoBufs                     = OT_ERROR_NO_BUFS;
58 constexpr Error kErrorNoRoute                    = OT_ERROR_NO_ROUTE;
59 constexpr Error kErrorBusy                       = OT_ERROR_BUSY;
60 constexpr Error kErrorParse                      = OT_ERROR_PARSE;
61 constexpr Error kErrorInvalidArgs                = OT_ERROR_INVALID_ARGS;
62 constexpr Error kErrorSecurity                   = OT_ERROR_SECURITY;
63 constexpr Error kErrorAddressQuery               = OT_ERROR_ADDRESS_QUERY;
64 constexpr Error kErrorNoAddress                  = OT_ERROR_NO_ADDRESS;
65 constexpr Error kErrorAbort                      = OT_ERROR_ABORT;
66 constexpr Error kErrorNotImplemented             = OT_ERROR_NOT_IMPLEMENTED;
67 constexpr Error kErrorInvalidState               = OT_ERROR_INVALID_STATE;
68 constexpr Error kErrorNoAck                      = OT_ERROR_NO_ACK;
69 constexpr Error kErrorChannelAccessFailure       = OT_ERROR_CHANNEL_ACCESS_FAILURE;
70 constexpr Error kErrorDetached                   = OT_ERROR_DETACHED;
71 constexpr Error kErrorFcs                        = OT_ERROR_FCS;
72 constexpr Error kErrorNoFrameReceived            = OT_ERROR_NO_FRAME_RECEIVED;
73 constexpr Error kErrorUnknownNeighbor            = OT_ERROR_UNKNOWN_NEIGHBOR;
74 constexpr Error kErrorInvalidSourceAddress       = OT_ERROR_INVALID_SOURCE_ADDRESS;
75 constexpr Error kErrorAddressFiltered            = OT_ERROR_ADDRESS_FILTERED;
76 constexpr Error kErrorDestinationAddressFiltered = OT_ERROR_DESTINATION_ADDRESS_FILTERED;
77 constexpr Error kErrorNotFound                   = OT_ERROR_NOT_FOUND;
78 constexpr Error kErrorAlready                    = OT_ERROR_ALREADY;
79 constexpr Error kErrorIp6AddressCreationFailure  = OT_ERROR_IP6_ADDRESS_CREATION_FAILURE;
80 constexpr Error kErrorNotCapable                 = OT_ERROR_NOT_CAPABLE;
81 constexpr Error kErrorResponseTimeout            = OT_ERROR_RESPONSE_TIMEOUT;
82 constexpr Error kErrorDuplicated                 = OT_ERROR_DUPLICATED;
83 constexpr Error kErrorReassemblyTimeout          = OT_ERROR_REASSEMBLY_TIMEOUT;
84 constexpr Error kErrorNotTmf                     = OT_ERROR_NOT_TMF;
85 constexpr Error kErrorNotLowpanDataFrame         = OT_ERROR_NOT_LOWPAN_DATA_FRAME;
86 constexpr Error kErrorLinkMarginLow              = OT_ERROR_LINK_MARGIN_LOW;
87 constexpr Error kErrorInvalidCommand             = OT_ERROR_INVALID_COMMAND;
88 constexpr Error kErrorPending                    = OT_ERROR_PENDING;
89 constexpr Error kErrorRejected                   = OT_ERROR_REJECTED;
90 constexpr Error kErrorGeneric                    = OT_ERROR_GENERIC;
91 
92 constexpr uint8_t kNumErrors = OT_NUM_ERRORS;
93 
94 /**
95  * Converts an `Error` into a string.
96  *
97  * @param[in]  aError     An error.
98  *
99  * @returns  A string representation of @p aError.
100  */
101 const char *ErrorToString(Error aError);
102 
103 } // namespace ot
104 
105 #endif // ERROR_HPP_
106