Matter SDK Coverage Report
Current view: top level - lib/core - CHIPError.h (source / functions) Coverage Total Hit
Test: SHA:e021a368d10ac6f3f201c101585146211fdcdaa2 Lines: 100.0 % 49 49
Test Date: 2026-02-13 08:13:38 Functions: 100.0 % 22 22

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2020-2025 Project CHIP Authors
       4              :  *    Copyright (c) 2013-2017 Nest Labs, Inc.
       5              :  *
       6              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       7              :  *    you may not use this file except in compliance with the License.
       8              :  *    You may obtain a copy of the License at
       9              :  *
      10              :  *        http://www.apache.org/licenses/LICENSE-2.0
      11              :  *
      12              :  *    Unless required by applicable law or agreed to in writing, software
      13              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      14              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15              :  *    See the License for the specific language governing permissions and
      16              :  *    limitations under the License.
      17              :  */
      18              : 
      19              : /**
      20              :  *    @file
      21              :  *      This file defines error constants for the CHIP core
      22              :  *      subsystem.
      23              :  *
      24              :  *      Error types, ranges, and mappings overrides may be made by
      25              :  *      defining the appropriate CHIP_CONFIG_* or _CHIP_CONFIG_*
      26              :  *      macros.
      27              :  */
      28              : 
      29              : #pragma once
      30              : 
      31              : #include <inttypes.h>
      32              : #include <limits>
      33              : #include <type_traits>
      34              : 
      35              : #include <lib/core/CHIPConfig.h>
      36              : #include <lib/support/TypeTraits.h>
      37              : 
      38              : #if CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
      39              : #include <source_location>
      40              : #endif
      41              : 
      42              : namespace chip {
      43              : 
      44              : /**
      45              :  * This class represents CHIP errors.
      46              :  *
      47              :  * At the top level, an error belongs to a Range and has an integral Value whose meaning depends on the Range.
      48              :  * One, Range::kSDK, is used for the CHIP SDK's own errors; others encapsulate error codes from external sources
      49              :  * (e.g. libraries, OS) into a CHIP_ERROR.
      50              :  *
      51              :  * CHIP SDK errors inside Range::kSDK consist of a component identifier given by SdkPart and an arbitrary small
      52              :  * integer Code.
      53              :  */
      54              : class [[nodiscard]] ChipError
      55              : {
      56              : public:
      57              :     /// Internal representation of an error.
      58              :     using StorageType = uint32_t;
      59              : 
      60              :     /// Type for encapsulated error values.
      61              :     using ValueType = int32_t;
      62              : 
      63              :     /// Integer `printf` format for errors. This is a C macro in order to allow for string literal concatenation.
      64              : #define CHIP_ERROR_INTEGER_FORMAT PRIx32
      65              : 
      66              : #if CHIP_CONFIG_ERROR_FORMAT_AS_STRING
      67              : 
      68              :     /// Type returned by Format().
      69              :     using FormatType = const char *;
      70              :     /// `printf` format for Format(). This is a C macro in order to allow for string literal concatenation.
      71              : #define CHIP_ERROR_FORMAT "s"
      72              : 
      73              : #else // CHIP_CONFIG_ERROR_FORMAT_AS_STRING
      74              : 
      75              :     /// Type returned by Format().
      76              :     using FormatType = StorageType;
      77              :     /// `printf` format for Format(). This is a C macro in order to allow for string literal concatenation.
      78              : #define CHIP_ERROR_FORMAT CHIP_ERROR_INTEGER_FORMAT
      79              : 
      80              : #endif // CHIP_CONFIG_ERROR_FORMAT_AS_STRING
      81              : 
      82              :     /**
      83              :      * Top-level error classification.
      84              :      *
      85              :      * Every error belongs to a Range and has an integral Value whose meaning depends on the Range.
      86              :      * All native CHIP SDK errors belong to the kSDK range. Other ranges are used to encapsulate error
      87              :      * codes from other subsystems (e.g. platform or library) used by the CHIP SDK.
      88              :      */
      89              :     enum class Range : uint8_t
      90              :     {
      91              :         kSDK        = 0x0, ///< CHIP SDK errors.
      92              :         kOS         = 0x1, ///< Encapsulated OS errors, other than POSIX errno.
      93              :         kPOSIX      = 0x2, ///< Encapsulated POSIX errno values.
      94              :         kLwIP       = 0x3, ///< Encapsulated LwIP errors.
      95              :         kOpenThread = 0x4, ///< Encapsulated OpenThread errors.
      96              :         kPlatform   = 0x5, ///< Platform-defined encapsulation.
      97              :         // Platform-defined encapsulation with 31-bit value. This is a special range which maximizes
      98              :         // the number of bits available for the encapsulated value. Such approach should minimize the
      99              :         // risk of value truncation when encapsulating platform-specific error codes. Since we do not
     100              :         // control platform-specific error codes we should not make assumptions about their size.
     101              :         kPlatformExtended = 0x80,
     102              :         kLastRange        = kPlatform,
     103              :     };
     104              : 
     105              :     /**
     106              :      * The kPlatformExtended value is a special range where the highest bit of the StorageType is set
     107              :      * to indicate platform encapsulation. Platform encapsulated errors use all the lower 31 bits for
     108              :      * the encapsulated value.
     109              :      */
     110              :     static_assert(Range::kLastRange < Range::kPlatformExtended, "The last range must be less than kPlatformExtended");
     111              : 
     112              :     /**
     113              :      * Secondary classification of CHIP SDK errors (Range::kSDK).
     114              :      */
     115              :     enum class SdkPart : uint8_t
     116              :     {
     117              :         kCore            = 0, ///< SDK core errors.
     118              :         kInet            = 1, ///< Inet layer errors; see <inet/InetError.h>.
     119              :         kDevice          = 2, ///< Device layer errors; see <platform/CHIPDeviceError.h>.
     120              :         kASN1            = 3, ///< ASN1 errors; see <asn1/ASN1Error.h>.
     121              :         kBLE             = 4, ///< BLE layer errors; see <ble/BleError.h>.
     122              :         kIMGlobalStatus  = 5, ///< Interaction Model global status code.
     123              :         kIMClusterStatus = 6, ///< Interaction Model cluster-specific status code.
     124              :         kApplication     = 7, ///< Application-defined errors; see CHIP_APPLICATION_ERROR
     125              :     };
     126              : 
     127              :     ChipError() = default;
     128              : 
     129              :     /**
     130              :      * Helper macro to provide a source location arguments to the ChipError constructor.
     131              :      */
     132              : #if CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     133              : #define CHIP_ERROR_SOURCE_LOCATION_NULL , std::source_location()
     134              : #define CHIP_ERROR_SOURCE_LOCATION , std::source_location::current()
     135              : #elif CHIP_CONFIG_ERROR_SOURCE
     136              : #define CHIP_ERROR_SOURCE_LOCATION_NULL , nullptr, 0
     137              : #define CHIP_ERROR_SOURCE_LOCATION , __FILE__, __LINE__
     138              : #else
     139              : #define CHIP_ERROR_SOURCE_LOCATION_NULL
     140              : #define CHIP_ERROR_SOURCE_LOCATION
     141              : #endif
     142              : 
     143              :     /**
     144              :      * Construct a CHIP_ERROR encapsulating @a value inside the Range @a range.
     145              :      *
     146              :      * @note
     147              :      *  The result is valid only if CanEncapsulate() is true.
     148              :      */
     149              : #if CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     150              :     constexpr ChipError(Range range, ValueType value, std::source_location location = std::source_location()) :
     151              :         mError(MakeInteger(range, MaskValue(range, value))), mSourceLocation(location)
     152              :     {}
     153              : #elif CHIP_CONFIG_ERROR_SOURCE
     154        21837 :     constexpr ChipError(Range range, ValueType value, const char * file = nullptr, unsigned int line = 0) :
     155        21837 :         mError(MakeInteger(range, MaskValue(range, value))), mLine(line), mFile(file)
     156        21837 :     {}
     157              : #else
     158              :     constexpr ChipError(Range range, ValueType value) : mError(MakeInteger(range, MaskValue(range, value))) {}
     159              : #endif
     160              : 
     161              :     /**
     162              :      *  Helper macro to construct a CHIP_ERROR from a range and a value.
     163              :      */
     164              : #define CHIP_GENERIC_ERROR(range, value) ::chip::ChipError(range, value CHIP_ERROR_SOURCE_LOCATION)
     165              : 
     166              :     /**
     167              :      * Construct a CHIP_ERROR for SdkPart @a part with @a code.
     168              :      *
     169              :      * @note
     170              :      *  The macro version CHIP_SDK_ERROR checks that the numeric value is constant and well-formed.
     171              :      */
     172              : #if CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     173              :     constexpr ChipError(SdkPart part, uint8_t code, std::source_location location = std::source_location()) :
     174              :         mError(MakeInteger(part, code)), mSourceLocation(location)
     175              :     {}
     176              : #elif CHIP_CONFIG_ERROR_SOURCE
     177          160 :     constexpr ChipError(SdkPart part, uint8_t code, const char * file = nullptr, unsigned int line = 0) :
     178          160 :         mError(MakeInteger(part, code)), mLine(line), mFile(file)
     179          160 :     {}
     180              : #else
     181              :     constexpr ChipError(SdkPart part, uint8_t code) : mError(MakeInteger(part, code)) {}
     182              : #endif
     183              : 
     184              :     /**
     185              :      * Construct a CHIP_ERROR constant for SdkPart @a part with @a code at the current source line.
     186              :      * This checks that the numeric value is constant and well-formed.
     187              :      * (In C++20 this could be replaced by a consteval constructor.)
     188              :      */
     189              : #define CHIP_SDK_ERROR(part, code)                                                                                                 \
     190              :     (::chip::ChipError(::chip::ChipError::SdkErrorConstant<(part), (code)>::value CHIP_ERROR_SOURCE_LOCATION))
     191              : 
     192              :     /**
     193              :      * Construct a CHIP_ERROR from the underlying storage type.
     194              :      *
     195              :      * @note
     196              :      *  This is intended to be used only in foreign function interfaces.
     197              :      */
     198              : #if CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     199              :     explicit constexpr ChipError(StorageType error, std::source_location location = std::source_location()) :
     200              :         mError(error), mSourceLocation(location)
     201              :     {}
     202              : #elif CHIP_CONFIG_ERROR_SOURCE
     203    269375173 :     explicit constexpr ChipError(StorageType error, const char * file = nullptr, unsigned int line = 0) :
     204    269375173 :         mError(error), mLine(line), mFile(file)
     205    269375173 :     {}
     206              : #else
     207              :     explicit constexpr ChipError(StorageType error) : mError(error) {}
     208              : #endif
     209              : 
     210              :     /**
     211              :      * Compare errors for equality.
     212              :      *
     213              :      * @note
     214              :      *  This only compares the error code. Under the CHIP_CONFIG_ERROR_SOURCE configuration, errors compare equal
     215              :      *  if they have the same error code, even if they have different source locations.
     216              :      */
     217              :     constexpr __attribute__((always_inline)) inline bool operator==(const ChipError & other) const
     218              :     {
     219      6148289 :         return mError == other.mError;
     220              :     }
     221              :     constexpr __attribute__((always_inline)) inline bool operator!=(const ChipError & other) const
     222              :     {
     223     57548429 :         return mError != other.mError;
     224              :     }
     225              : 
     226              :     /**
     227              :      * Return an integer code for the error.
     228              :      */
     229         2990 :     constexpr StorageType AsInteger() const { return mError; }
     230              : 
     231              :     /*
     232              :      * IsSuccess() is intended to support macros that can take either a ChipError or an integer error code.
     233              :      * The latter follows the C convention that a non-zero integer indicates an error.
     234              :      *
     235              :      * @note
     236              :      *  Normal code should use `status == CHIP_NO_ERROR` rather than `IsSuccess(status)`.
     237              :      */
     238    134472706 :     static constexpr bool IsSuccess(ChipError error) { return error.mError == 0; }
     239              :     static constexpr bool IsSuccess(StorageType error) { return error == 0; }
     240              : 
     241              :     /**
     242              :      * Format an @a error for printing.
     243              :      *
     244              :      * Normally, this is used with the `printf()`-style macro CHIP_ERROR_FORMAT.
     245              :      * For example,
     246              :      *  @code
     247              :      *      ChipLogError(subsystem, "A bad thing happened! %" CHIP_ERROR_FORMAT, status.Format());
     248              :      *  @endcode
     249              :      */
     250              : #if CHIP_CONFIG_ERROR_FORMAT_AS_STRING
     251          703 :     FormatType Format() const { return AsString(); }
     252              : #else  // CHIP_CONFIG_ERROR_FORMAT_AS_STRING
     253              :     FormatType Format() const { return mError; }
     254              : #endif // CHIP_CONFIG_ERROR_FORMAT_AS_STRING
     255              : 
     256              :     /**
     257              :      * Format an @a error as a string for printing.
     258              :      *
     259              :      * @note
     260              :      *  Normally, prefer to use Format()
     261              :      */
     262         5862 :     const char * AsString(bool withSourceLocation = true) const
     263              :     {
     264              :         extern const char * ErrorStr(ChipError, bool);
     265         5862 :         return ErrorStr(*this, withSourceLocation);
     266              :     }
     267              : 
     268              :     /**
     269              :      * Test whether @a error belongs to the Range @a range.
     270              :      */
     271           76 :     constexpr bool IsRange(Range range) const { return range == GetRange(); }
     272              : 
     273              :     /**
     274              :      * Get the Range to which the @a error belongs.
     275              :      */
     276           80 :     constexpr Range GetRange() const
     277              :     {
     278           80 :         if (mError & (1u << kPlatformBit))
     279              :         {
     280            8 :             return Range::kPlatformExtended;
     281              :         }
     282           72 :         return static_cast<Range>(GetField(kRangeStartBit, kRangeLength, mError));
     283              :     }
     284              : 
     285              :     /**
     286              :      * Get the encapsulated value of an @a error.
     287              :      */
     288           21 :     constexpr ValueType GetValue() const
     289              :     {
     290           21 :         if (mError & (1u << kPlatformBit))
     291              :         {
     292            4 :             return GetField<ValueType>(kPlatformValueStart, kPlatformValueLength, mError);
     293              :         }
     294           17 :         return GetField<ValueType>(kValueStartBit, kValueLength, mError);
     295              :     }
     296              : 
     297              :     /**
     298              :      * Test whether @a value type can be losslessly encapsulated in a CHIP_ERROR.
     299              :      *
     300              :      * @note
     301              :      * This function does not check the actual value, only the type T.
     302              :      */
     303              :     template <typename T>
     304              :     static constexpr bool CanEncapsulate(Range range, T value)
     305              :     {
     306              :         if (range == Range::kPlatformExtended)
     307              :         {
     308              :             return std::numeric_limits<T>::min() >= kPlatformValueMin && std::numeric_limits<T>::max() <= kPlatformValueMax;
     309              :         }
     310              :         return std::numeric_limits<T>::min() >= kValueMin && std::numeric_limits<T>::max() <= kValueMax;
     311              :     }
     312              : 
     313              :     /**
     314              :      * Test whether @a error is an SDK error belonging to the SdkPart @a part.
     315              :      */
     316         8683 :     constexpr bool IsPart(SdkPart part) const
     317              :     {
     318         8683 :         return (mError & (MakeMask(kRangeStartBit, kRangeLength) | MakeMask(kSdkPartStartBit, kSdkPartLength))) ==
     319         8683 :             (MakeField(kRangeStartBit, static_cast<StorageType>(Range::kSDK)) |
     320         8683 :              MakeField(kSdkPartStartBit, static_cast<StorageType>(part)));
     321              :     }
     322              : 
     323              :     /**
     324              :      * Get the SDK code for an SDK error.
     325              :      */
     326           88 :     constexpr uint8_t GetSdkCode() const { return static_cast<uint8_t>(GetField(kSdkCodeStartBit, kSdkCodeLength, mError)); }
     327              : 
     328              :     /**
     329              :      * Test whether @a error is an SDK error representing an Interaction Model
     330              :      * status.  If it is, it can be converted to/from an interaction model
     331              :      * StatusIB struct.
     332              :      */
     333          529 :     constexpr bool IsIMStatus() const
     334              :     {
     335              :         // Open question: should CHIP_NO_ERROR be treated as an IM status for
     336              :         // purposes of this test?
     337          529 :         return IsPart(SdkPart::kIMGlobalStatus) || IsPart(SdkPart::kIMClusterStatus);
     338              :     }
     339              : 
     340              : #if CHIP_CONFIG_ERROR_SOURCE
     341              : 
     342              :     /**
     343              :      * Get the source file name of the point where the error occurred.
     344              :      *
     345              :      * @note
     346              :      *  This will be `nullptr` if the error was not created with a file name.
     347              :      */
     348         6996 :     const char * GetFile() const
     349              :     {
     350              : #if CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     351              :         return mSourceLocation.file_name();
     352              : #else
     353         6996 :         return mFile;
     354              : #endif
     355              :     }
     356              : 
     357              :     /**
     358              :      * Get the source line number of the point where the error occurred.
     359              :      *
     360              :      * @note
     361              :      *  This will be 0 if the error was not created with a file name.
     362              :      */
     363         1024 :     unsigned int GetLine() const
     364              :     {
     365              : #if CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     366              :         return mSourceLocation.line();
     367              : #else
     368         1024 :         return mLine;
     369              : #endif
     370              :     }
     371              : 
     372              : #if CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     373              :     /**
     374              :      * Get the source_location of the point where the error occurred.
     375              :      */
     376              :     const std::source_location & GetSourceLocation() { return mSourceLocation; }
     377              : #endif // CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     378              : 
     379              : #endif // CHIP_CONFIG_ERROR_SOURCE
     380              : 
     381              :     // Helper method to convert common failures which are expected into CHIP_NO_ERROR.
     382              :     ChipError NoErrorIf(ChipError suppressed);
     383              : 
     384              : private:
     385              :     /*
     386              :      * The representation of a CHIP_ERROR is structured so that SDK error code constants are small, in order to improve code
     387              :      * density on embedded builds. Arm 32, Xtensa, and RISC-V can all handle 11-bit values in a move-immediate instruction.
     388              :      * Further, SdkPart::kCore is 0 so that the most common errors fit in 8 bits for additional density on some processors.
     389              :      *
     390              :      *  31    28      24      20      16      12       8       4       0    Bit
     391              :      *  |       |       |       |       |       |       |       |       |
     392              :      *  |     range     |                     value                     |
     393              :      *  |    kSdk==0    |       0               |0| part|    code       |   SDK error
     394              :      *  |    01 - 7F    |          encapsulated error code              |   Encapsulated error
     395              :      *  |1|                   encapsulated platform error code          |   Encapsulated platform error
     396              :      */
     397              :     static constexpr int kRangeStartBit = 24;
     398              :     static constexpr int kRangeLength   = 8;
     399              :     static constexpr int kValueStartBit = 0;
     400              :     static constexpr int kValueLength   = 24;
     401              :     static constexpr int kValueMax      = (1u << kValueLength) - 1;
     402              :     static constexpr int kValueMin      = -kValueMax - 1;
     403              : 
     404              :     static constexpr int kPlatformBit         = 31;
     405              :     static constexpr int kPlatformValueStart  = 0;
     406              :     static constexpr int kPlatformValueLength = 31;
     407              :     static constexpr int kPlatformValueMax    = (1u << kPlatformValueLength) - 1;
     408              :     static constexpr int kPlatformValueMin    = -kPlatformValueMax - 1;
     409              : 
     410              :     static constexpr int kSdkPartStartBit = 8;
     411              :     static constexpr int kSdkPartLength   = 3;
     412              :     static constexpr int kSdkCodeStartBit = 0;
     413              :     static constexpr int kSdkCodeLength   = 8;
     414              : 
     415              :     template <typename T = StorageType>
     416          181 :     static constexpr T GetField(unsigned int start, unsigned int length, StorageType value)
     417              :     {
     418              :         // For signed types T, the right shift performs sign extension, so the following code
     419              :         // correctly preserves the sign of the extracted field.
     420          181 :         return static_cast<T>(value << (std::numeric_limits<decltype(value)>::digits - start - length)) >>
     421          181 :             (std::numeric_limits<decltype(value)>::digits - length);
     422              :     }
     423              : 
     424        39203 :     static constexpr StorageType MakeMask(unsigned int start, unsigned int length) { return ((1u << length) - 1) << start; }
     425        61680 :     static constexpr StorageType MakeField(unsigned int start, StorageType value) { return value << start; }
     426              :     static constexpr bool FitsInField(unsigned int length, StorageType value) { return value < (1u << length); }
     427              : 
     428        21997 :     static constexpr StorageType MakeInteger(Range range, StorageType value)
     429              :     {
     430        21997 :         return MakeField(kRangeStartBit, to_underlying(range)) | MakeField(kValueStartBit, value);
     431              :     }
     432          160 :     static constexpr StorageType MakeInteger(SdkPart part, uint8_t code)
     433              :     {
     434          160 :         return MakeInteger(Range::kSDK, MakeField(kSdkPartStartBit, to_underlying(part)) | MakeField(kSdkCodeStartBit, code));
     435              :     }
     436              : 
     437              :     // Clear all bits outside the value field.
     438              :     //
     439              :     // This function does not mask the value for the kPlatformExtended range because in
     440              :     // case of kPlatformExtended the entire lower 31 bits are used for the value and the
     441              :     // highest bit is set anyway to indicate this special range.
     442        21837 :     static constexpr StorageType MaskValue(Range range, ValueType value)
     443              :     {
     444              :         // No masking is needed for kPlatformExtended because MakeInteger will set the MSB.
     445        21837 :         return (range != Range::kPlatformExtended) ? (static_cast<StorageType>(value) & MakeMask(kValueStartBit, kValueLength))
     446        21837 :                                                    : static_cast<StorageType>(value);
     447              :     }
     448              : 
     449              :     template <unsigned int START, unsigned int LENGTH>
     450              :     struct MaskConstant
     451              :     {
     452              :         static constexpr StorageType value = ((1u << LENGTH) - 1) << START;
     453              :     };
     454              : 
     455              :     // Assert that Range and Value fields fit in StorageType and don't overlap.
     456              :     static_assert(kRangeStartBit + kRangeLength <= std::numeric_limits<StorageType>::digits, "Range does not fit in StorageType");
     457              :     static_assert(kValueStartBit + kValueLength <= std::numeric_limits<StorageType>::digits, "Value does not fit in StorageType");
     458              :     static_assert((MaskConstant<kRangeStartBit, kRangeLength>::value & MaskConstant<kValueStartBit, kValueLength>::value) == 0,
     459              :                   "Range and Value overlap");
     460              : 
     461              :     // Assert that SDK Part and Code fields fit in SdkCode field and don't overlap.
     462              :     static_assert(kSdkPartStartBit + kSdkPartLength <= kValueLength, "SdkPart does not fit in Value");
     463              :     static_assert(kSdkCodeStartBit + kSdkCodeLength <= kValueLength, "SdkCode does not fit in Value");
     464              :     static_assert((MaskConstant<kSdkPartStartBit, kSdkPartLength>::value & MaskConstant<kSdkCodeStartBit, kSdkCodeLength>::value) ==
     465              :                       0,
     466              :                   "SdkPart and SdkCode overlap");
     467              : 
     468              :     // Assert that value fits in ValueType.
     469              :     static_assert(kValueStartBit + kValueLength <= std::numeric_limits<ValueType>::digits, "Value does not fit in ValueType");
     470              :     static_assert(kPlatformValueStart + kPlatformValueLength <= std::numeric_limits<ValueType>::digits,
     471              :                   "Platform value does not fit in ValueType");
     472              : 
     473              :     StorageType mError;
     474              : 
     475              : #if CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_STD_SOURCE_LOCATION
     476              :     std::source_location mSourceLocation;
     477              : #elif CHIP_CONFIG_ERROR_SOURCE
     478              :     unsigned int mLine;
     479              :     const char * mFile;
     480              : #endif
     481              : 
     482              : public:
     483              :     /**
     484              :      * Helper for constructing error constants.
     485              :      *
     486              :      * This template ensures that the numeric value is constant and well-formed.
     487              :      */
     488              :     template <SdkPart PART, StorageType SCODE>
     489              :     struct SdkErrorConstant
     490              :     {
     491              :         static_assert(FitsInField(kSdkPartLength, to_underlying(PART)), "part is too large");
     492              :         static_assert(FitsInField(kSdkCodeLength, SCODE), "code is too large");
     493              :         static_assert(MakeInteger(PART, SCODE) != 0, "value is zero");
     494              :         static constexpr StorageType value = MakeInteger(PART, SCODE);
     495              :     };
     496              : };
     497              : 
     498              : } // namespace chip
     499              : 
     500              : /**
     501              :  *  The basic type for all CHIP errors.
     502              :  */
     503              : using CHIP_ERROR = ::chip::ChipError;
     504              : 
     505              : /**
     506              :  * Applications using the CHIP SDK can use this to define error codes in the CHIP_ERROR space for their own purposes.
     507              :  * This is suitable for a small fixed set of errors, similar to `CHIP_ERROR_…` constants. For embedding arbitrary or
     508              :  * larger values, use a custom Range offset from Range::kLastRange.
     509              :  */
     510              : #define CHIP_APPLICATION_ERROR(e) CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kApplication, (e))
     511              : 
     512              : #define CHIP_CORE_ERROR(e) CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kCore, (e))
     513              : 
     514              : #define CHIP_IM_GLOBAL_STATUS(type)                                                                                                \
     515              :     CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kIMGlobalStatus,                                                                    \
     516              :                    ::chip::to_underlying(::chip::Protocols::InteractionModel::Status::type))
     517              : 
     518              : // Defines a runtime-value for a chip-error that contains a global IM Status.
     519              : #define CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status_value)                                                                            \
     520              :     CHIP_GENERIC_ERROR(::chip::ChipError::SdkPart::kIMGlobalStatus, ::chip::to_underlying(status_value))
     521              : 
     522              : //
     523              : // type must be a compile-time constant as mandated by CHIP_SDK_ERROR.
     524              : //
     525              : #define CHIP_IM_CLUSTER_STATUS(type) CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kIMClusterStatus, type)
     526              : 
     527              : // Defines a runtime-value for a chip-error that contains a cluster-specific error status.
     528              : // Must not be used with cluster-specific success status codes.
     529              : #define CHIP_ERROR_IM_CLUSTER_STATUS_VALUE(status_value)                                                                           \
     530              :     CHIP_GENERIC_ERROR(::chip::ChipError::SdkPart::kIMClusterStatus, status_value)
     531              : 
     532              : // clang-format off
     533              : 
     534              : /**
     535              :  *  @name Error Definitions
     536              :  *
     537              :  *  @{
     538              :  */
     539              : 
     540              : /**
     541              :  *  @def CHIP_NO_ERROR
     542              :  *
     543              :  *  @brief
     544              :  *    This defines the CHIP error code for success or no error.
     545              :  *
     546              :  */
     547              : #if CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_SOURCE_NO_ERROR
     548              : #define CHIP_NO_ERROR                                          CHIP_ERROR(0 CHIP_ERROR_SOURCE_LOCATION)
     549              : #else // CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_SOURCE_NO_ERROR
     550              : #define CHIP_NO_ERROR                                          CHIP_ERROR(0 CHIP_ERROR_SOURCE_LOCATION_NULL)
     551              : #endif // CHIP_CONFIG_ERROR_SOURCE && CHIP_CONFIG_ERROR_SOURCE_NO_ERROR
     552              : 
     553              : /**
     554              :  *  @def CHIP_ERROR_SENDING_BLOCKED
     555              :  *
     556              :  *  @brief
     557              :  *    A message exceeds the sent limit.
     558              :  *
     559              :  */
     560              : #define CHIP_ERROR_SENDING_BLOCKED                             CHIP_CORE_ERROR(0x01)
     561              : 
     562              : /**
     563              :  *  @def CHIP_ERROR_CONNECTION_ABORTED
     564              :  *
     565              :  *  @brief
     566              :  *    A connection has been aborted.
     567              :  *
     568              :  */
     569              : #define CHIP_ERROR_CONNECTION_ABORTED                          CHIP_CORE_ERROR(0x02)
     570              : 
     571              : /**
     572              :  *  @def CHIP_ERROR_INCORRECT_STATE
     573              :  *
     574              :  *  @brief
     575              :  *    An unexpected state was encountered.
     576              :  *
     577              :  */
     578              : #define CHIP_ERROR_INCORRECT_STATE                             CHIP_CORE_ERROR(0x03)
     579              : 
     580              : /**
     581              :  *  @def CHIP_ERROR_MESSAGE_TOO_LONG
     582              :  *
     583              :  *  @brief
     584              :  *    A message is too long.
     585              :  *
     586              :  */
     587              : #define CHIP_ERROR_MESSAGE_TOO_LONG                            CHIP_CORE_ERROR(0x04)
     588              : 
     589              : /**
     590              :  *    Recursion depth overflow
     591              :  */
     592              : #define CHIP_ERROR_RECURSION_DEPTH_LIMIT                       CHIP_CORE_ERROR(0x05)
     593              : 
     594              : /**
     595              :  *  @def CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS
     596              :  *
     597              :  *  @brief
     598              :  *    The attempt to register an unsolicited message handler failed because the
     599              :  *    unsolicited message handler pool is full.
     600              :  *
     601              :  */
     602              : #define CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS       CHIP_CORE_ERROR(0x06)
     603              : 
     604              : /**
     605              :  *  @def CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER
     606              :  *
     607              :  *  @brief
     608              :  *    The attempt to unregister an unsolicited message handler failed because
     609              :  *    the target handler was not found in the unsolicited message handler pool.
     610              :  *
     611              :  */
     612              : #define CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER              CHIP_CORE_ERROR(0x07)
     613              : 
     614              : /**
     615              :  *  @def CHIP_ERROR_NO_CONNECTION_HANDLER
     616              :  *
     617              :  *  @brief
     618              :  *    No callback has been registered for handling a connection.
     619              :  *
     620              :  */
     621              : #define CHIP_ERROR_NO_CONNECTION_HANDLER                       CHIP_CORE_ERROR(0x08)
     622              : 
     623              : /**
     624              :  *  @def CHIP_ERROR_TOO_MANY_PEER_NODES
     625              :  *
     626              :  *  @brief
     627              :  *    The number of peer nodes exceeds the maximum limit of a local node.
     628              :  *
     629              :  */
     630              : #define CHIP_ERROR_TOO_MANY_PEER_NODES                         CHIP_CORE_ERROR(0x09)
     631              : 
     632              : /**
     633              :  *  @def CHIP_ERROR_SENTINEL
     634              :  *
     635              :  *  @brief
     636              :  *    For use locally to mark conditions such as value found or end of iteration.
     637              :  *
     638              :  */
     639              : #define CHIP_ERROR_SENTINEL                                    CHIP_CORE_ERROR(0x0a)
     640              : 
     641              : /**
     642              :  *  @def CHIP_ERROR_NO_MEMORY
     643              :  *
     644              :  *  @brief
     645              :  *    The attempt to allocate a buffer or object failed due to a lack of memory.
     646              :  *
     647              :  */
     648              : #define CHIP_ERROR_NO_MEMORY                                   CHIP_CORE_ERROR(0x0b)
     649              : 
     650              : /**
     651              :  *  @def CHIP_ERROR_NO_MESSAGE_HANDLER
     652              :  *
     653              :  *  @brief
     654              :  *    No callback has been registered for handling a message.
     655              :  *
     656              :  */
     657              : #define CHIP_ERROR_NO_MESSAGE_HANDLER                          CHIP_CORE_ERROR(0x0c)
     658              : 
     659              : /**
     660              :  *  @def CHIP_ERROR_MESSAGE_INCOMPLETE
     661              :  *
     662              :  *  @brief
     663              :  *    A message is incomplete.
     664              :  *
     665              :  */
     666              : #define CHIP_ERROR_MESSAGE_INCOMPLETE                          CHIP_CORE_ERROR(0x0d)
     667              : 
     668              : /**
     669              :  *  @def CHIP_ERROR_DATA_NOT_ALIGNED
     670              :  *
     671              :  *  @brief
     672              :  *    The data is not aligned.
     673              :  *
     674              :  */
     675              : #define CHIP_ERROR_DATA_NOT_ALIGNED                            CHIP_CORE_ERROR(0x0e)
     676              : 
     677              : /**
     678              :  *  @def CHIP_ERROR_UNKNOWN_KEY_TYPE
     679              :  *
     680              :  *  @brief
     681              :  *    The encryption key type is unknown.
     682              :  *
     683              :  */
     684              : #define CHIP_ERROR_UNKNOWN_KEY_TYPE                            CHIP_CORE_ERROR(0x0f)
     685              : 
     686              : /**
     687              :  *  @def CHIP_ERROR_KEY_NOT_FOUND
     688              :  *
     689              :  *  @brief
     690              :  *    The encryption key is not found.
     691              :  *
     692              :  */
     693              : #define CHIP_ERROR_KEY_NOT_FOUND                               CHIP_CORE_ERROR(0x10)
     694              : 
     695              : /**
     696              :  *  @def CHIP_ERROR_WRONG_ENCRYPTION_TYPE
     697              :  *
     698              :  *  @brief
     699              :  *    The encryption type is incorrect for the specified key.
     700              :  *
     701              :  */
     702              : #define CHIP_ERROR_WRONG_ENCRYPTION_TYPE                       CHIP_CORE_ERROR(0x11)
     703              : 
     704              : /**
     705              :  *  @def CHIP_ERROR_INVALID_UTF8
     706              :  *
     707              :  *  @brief
     708              :  *    Invalid UTF8 string (contains some characters that are invalid)
     709              :  *
     710              :  */
     711              : #define CHIP_ERROR_INVALID_UTF8                                CHIP_CORE_ERROR(0x12)
     712              : 
     713              : /**
     714              :  *  @def CHIP_ERROR_INTEGRITY_CHECK_FAILED
     715              :  *
     716              :  *  @brief
     717              :  *    The integrity check in the message does not match the expected integrity
     718              :  *    check.
     719              :  *
     720              :  */
     721              : #define CHIP_ERROR_INTEGRITY_CHECK_FAILED                      CHIP_CORE_ERROR(0x13)
     722              : 
     723              : /**
     724              :  *  @def CHIP_ERROR_INVALID_SIGNATURE
     725              :  *
     726              :  *  @brief
     727              :  *    Invalid signature.
     728              :  *
     729              :  */
     730              : #define CHIP_ERROR_INVALID_SIGNATURE                           CHIP_CORE_ERROR(0x14)
     731              : 
     732              : /**
     733              :  *  @def CHIP_ERROR_INVALID_TLV_CHAR_STRING
     734              :  *
     735              :  *  @brief
     736              :  *    Invalid TLV character string (e.g. null terminator)
     737              :  *
     738              :  */
     739              : #define CHIP_ERROR_INVALID_TLV_CHAR_STRING                     CHIP_CORE_ERROR(0x15)
     740              : 
     741              : /**
     742              :  *  @def CHIP_ERROR_LIT_SUBSCRIBE_INACTIVE_TIMEOUT
     743              :  *
     744              :  *  @brief
     745              :  *    Subscription timeout caused by LIT ICD device inactive mode
     746              :  *
     747              :  */
     748              : #define CHIP_ERROR_LIT_SUBSCRIBE_INACTIVE_TIMEOUT              CHIP_CORE_ERROR(0x16)
     749              : 
     750              : /**
     751              :  *  @def CHIP_ERROR_UNSUPPORTED_SIGNATURE_TYPE
     752              :  *
     753              :  *  @brief
     754              :  *    A signature type is unsupported.
     755              :  *
     756              :  */
     757              : #define CHIP_ERROR_UNSUPPORTED_SIGNATURE_TYPE                  CHIP_CORE_ERROR(0x17)
     758              : 
     759              : /**
     760              :  *  @def CHIP_ERROR_INVALID_MESSAGE_LENGTH
     761              :  *
     762              :  *  @brief
     763              :  *    A message length is invalid.
     764              :  *
     765              :  */
     766              : #define CHIP_ERROR_INVALID_MESSAGE_LENGTH                      CHIP_CORE_ERROR(0x18)
     767              : 
     768              : /**
     769              :  *  @def CHIP_ERROR_BUFFER_TOO_SMALL
     770              :  *
     771              :  *  @brief
     772              :  *    A buffer is too small.
     773              :  *
     774              :  */
     775              : #define CHIP_ERROR_BUFFER_TOO_SMALL                            CHIP_CORE_ERROR(0x19)
     776              : 
     777              : /**
     778              :  *  @def CHIP_ERROR_DUPLICATE_KEY_ID
     779              :  *
     780              :  *  @brief
     781              :  *    A key id is duplicate.
     782              :  *
     783              :  */
     784              : #define CHIP_ERROR_DUPLICATE_KEY_ID                            CHIP_CORE_ERROR(0x1a)
     785              : 
     786              : /**
     787              :  *  @def CHIP_ERROR_WRONG_KEY_TYPE
     788              :  *
     789              :  *  @brief
     790              :  *    A key type does not match the expected key type.
     791              :  *
     792              :  */
     793              : #define CHIP_ERROR_WRONG_KEY_TYPE                              CHIP_CORE_ERROR(0x1b)
     794              : 
     795              : /**
     796              :  *  @def CHIP_ERROR_UNINITIALIZED
     797              :  *
     798              :  *  @brief
     799              :  *    A requested object is uninitialized.
     800              :  *
     801              :  */
     802              : #define CHIP_ERROR_UNINITIALIZED                               CHIP_CORE_ERROR(0x1c)
     803              : 
     804              : /**
     805              :  *  @def CHIP_ERROR_INVALID_IPK
     806              :  *
     807              :  *  @brief
     808              :  *    The IPK is invalid
     809              :  *
     810              :  */
     811              : #define CHIP_ERROR_INVALID_IPK                                 CHIP_CORE_ERROR(0x1d)
     812              : 
     813              : /**
     814              :  *  @def CHIP_ERROR_INVALID_STRING_LENGTH
     815              :  *
     816              :  *  @brief
     817              :  *    A string length is invalid.
     818              :  *
     819              :  */
     820              : #define CHIP_ERROR_INVALID_STRING_LENGTH                       CHIP_CORE_ERROR(0x1e)
     821              : 
     822              : /**
     823              :  *  @def CHIP_ERROR_INVALID_LIST_LENGTH
     824              :  *
     825              :  *  @brief
     826              :  *    A list length is invalid.
     827              :  *
     828              :  */
     829              : #define CHIP_ERROR_INVALID_LIST_LENGTH                         CHIP_CORE_ERROR(0x1f)
     830              : 
     831              : /**
     832              :  *  @def CHIP_ERROR_FAILED_DEVICE_ATTESTATION
     833              :  *
     834              :  *  @brief
     835              :  *    Device Attestation failed.
     836              :  *
     837              :  */
     838              : #define CHIP_ERROR_FAILED_DEVICE_ATTESTATION                   CHIP_CORE_ERROR(0x20)
     839              : 
     840              : /**
     841              :  *  @def CHIP_END_OF_TLV
     842              :  *
     843              :  *  @brief
     844              :  *    The end of a TLV encoding,
     845              :  *    or the end of a TLV container element has been reached.
     846              :  *
     847              :  */
     848              : #define CHIP_ERROR_END_OF_TLV                                  CHIP_CORE_ERROR(0x21)
     849              : #define CHIP_END_OF_TLV CHIP_ERROR_END_OF_TLV
     850              : 
     851              : /**
     852              :  *  @def CHIP_ERROR_TLV_UNDERRUN
     853              :  *
     854              :  *  @brief
     855              :  *    The TLV encoding ended prematurely.
     856              :  *
     857              :  */
     858              : #define CHIP_ERROR_TLV_UNDERRUN                                CHIP_CORE_ERROR(0x22)
     859              : 
     860              : /**
     861              :  *  @def CHIP_ERROR_INVALID_TLV_ELEMENT
     862              :  *
     863              :  *  @brief
     864              :  *    A TLV element is invalid.
     865              :  *
     866              :  */
     867              : #define CHIP_ERROR_INVALID_TLV_ELEMENT                         CHIP_CORE_ERROR(0x23)
     868              : 
     869              : /**
     870              :  *  @def CHIP_ERROR_INVALID_TLV_TAG
     871              :  *
     872              :  *  @brief
     873              :  *    A TLV tag is invalid.
     874              :  *
     875              :  */
     876              : #define CHIP_ERROR_INVALID_TLV_TAG                             CHIP_CORE_ERROR(0x24)
     877              : 
     878              : /**
     879              :  *  @def CHIP_ERROR_UNKNOWN_IMPLICIT_TLV_TAG
     880              :  *
     881              :  *  @brief
     882              :  *    An implicitly encoded TLV tag was encountered,
     883              :  *    but an implicit profile id has not been defined.
     884              :  *
     885              :  */
     886              : #define CHIP_ERROR_UNKNOWN_IMPLICIT_TLV_TAG                    CHIP_CORE_ERROR(0x25)
     887              : 
     888              : /**
     889              :  *  @def CHIP_ERROR_WRONG_TLV_TYPE
     890              :  *
     891              :  *  @brief
     892              :  *    A TLV type is wrong.
     893              :  *
     894              :  */
     895              : #define CHIP_ERROR_WRONG_TLV_TYPE                              CHIP_CORE_ERROR(0x26)
     896              : 
     897              : /**
     898              :  *  @def CHIP_ERROR_TLV_CONTAINER_OPEN
     899              :  *
     900              :  *  @brief
     901              :  *    A TLV container is unexpectedly open.
     902              :  *
     903              :  */
     904              : #define CHIP_ERROR_TLV_CONTAINER_OPEN                          CHIP_CORE_ERROR(0x27)
     905              : 
     906              : /**
     907              :  *  @def CHIP_ERROR_IN_USE
     908              :  *
     909              :  *  @brief
     910              :  *    A value is already used. Generally indicates an unavailable resource.
     911              :  *    As opposed to CHIP_ERROR_BUSY, the use is not considered transient/temporary.
     912              :  *
     913              :  */
     914              : #define CHIP_ERROR_IN_USE                                      CHIP_CORE_ERROR(0x28)
     915              : 
     916              : /**
     917              :  *  @def CHIP_ERROR_HAD_FAILURES
     918              :  *
     919              :  *  @brief
     920              :  *    Report a multi-part operation as having had failures.
     921              :  *    This is used as an aggregate of a single CHIP_ERROR when several underlying
     922              :  *    calls may have failed and no single point of failure is reported.
     923              :  */
     924              : #define CHIP_ERROR_HAD_FAILURES                                CHIP_CORE_ERROR(0x29)
     925              : 
     926              : /**
     927              :  *  @def CHIP_ERROR_INVALID_MESSAGE_TYPE
     928              :  *
     929              :  *  @brief
     930              :  *    A message type is invalid.
     931              :  *
     932              :  */
     933              : #define CHIP_ERROR_INVALID_MESSAGE_TYPE                        CHIP_CORE_ERROR(0x2a)
     934              : 
     935              : /**
     936              :  *  @def CHIP_ERROR_UNEXPECTED_TLV_ELEMENT
     937              :  *
     938              :  *  @brief
     939              :  *    An unexpected TLV element was encountered.
     940              :  *
     941              :  */
     942              : #define CHIP_ERROR_UNEXPECTED_TLV_ELEMENT                      CHIP_CORE_ERROR(0x2b)
     943              : 
     944              : /**
     945              :  *  @def CHIP_ERROR_ALREADY_INITIALIZED
     946              :  *
     947              :  *  @brief
     948              :  *    Mark that an object has already beein initialized and cannot be
     949              :  *    initialized again
     950              :  *
     951              :  */
     952              : #define CHIP_ERROR_ALREADY_INITIALIZED                        CHIP_CORE_ERROR(0x2c)
     953              : 
     954              : /**
     955              :  *  @def CHIP_ERROR_NOT_IMPLEMENTED
     956              :  *
     957              :  *  @brief
     958              :  *    A requested function or feature is not implemented.
     959              :  *
     960              :  */
     961              : #define CHIP_ERROR_NOT_IMPLEMENTED                             CHIP_CORE_ERROR(0x2d)
     962              : 
     963              : /**
     964              :  *  @def CHIP_ERROR_INVALID_ADDRESS
     965              :  *
     966              :  *  @brief
     967              :  *    An address is invalid.
     968              :  *
     969              :  */
     970              : #define CHIP_ERROR_INVALID_ADDRESS                             CHIP_CORE_ERROR(0x2e)
     971              : 
     972              : /**
     973              :  *  @def CHIP_ERROR_INVALID_ARGUMENT
     974              :  *
     975              :  *  @brief
     976              :  *    An argument is invalid.
     977              :  *
     978              :  */
     979              : #define CHIP_ERROR_INVALID_ARGUMENT                            CHIP_CORE_ERROR(0x2f)
     980              : 
     981              : /**
     982              :  *  @def CHIP_ERROR_INVALID_PATH_LIST
     983              :  *
     984              :  *  @brief
     985              :  *    A TLV path list is invalid.
     986              :  *
     987              :  */
     988              : #define CHIP_ERROR_INVALID_PATH_LIST                           CHIP_CORE_ERROR(0x30)
     989              : 
     990              : /**
     991              :  *  @def CHIP_ERROR_INVALID_DATA_LIST
     992              :  *
     993              :  *  @brief
     994              :  *    A TLV data list is invalid.
     995              :  *
     996              :  */
     997              : #define CHIP_ERROR_INVALID_DATA_LIST                           CHIP_CORE_ERROR(0x31)
     998              : 
     999              : /**
    1000              :  *  @def CHIP_ERROR_TIMEOUT
    1001              :  *
    1002              :  *  @brief
    1003              :  *    A request timed out.
    1004              :  *
    1005              :  */
    1006              : #define CHIP_ERROR_TIMEOUT                                     CHIP_CORE_ERROR(0x32)
    1007              : 
    1008              : /**
    1009              :  *  @def CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR
    1010              :  *
    1011              :  *  @brief
    1012              :  *    A device descriptor is invalid.
    1013              :  *
    1014              :  */
    1015              : #define CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR                   CHIP_CORE_ERROR(0x33)
    1016              : 
    1017              : /**
    1018              :  *  @def CHIP_ERROR_UNSUPPORTED_DNSSD_SERVICE_NAME
    1019              :  *
    1020              :  *  @brief
    1021              :  *    The DNSSD service name is not a supported/recognized type.
    1022              :  *
    1023              :  */
    1024              : #define CHIP_ERROR_UNSUPPORTED_DNSSD_SERVICE_NAME               CHIP_CORE_ERROR(0x34)
    1025              : 
    1026              : // AVAILABLE: 0x35
    1027              : // AVAILABLE: 0x36
    1028              : // AVAILABLE: 0x37
    1029              : 
    1030              : /**
    1031              :  *  @def CHIP_ERROR_INVALID_PASE_PARAMETER
    1032              :  *
    1033              :  *  @brief
    1034              :  *    A PASE parameter is invalid.
    1035              :  *
    1036              :  */
    1037              : #define CHIP_ERROR_INVALID_PASE_PARAMETER                      CHIP_CORE_ERROR(0x38)
    1038              : 
    1039              : // AVAILABLE: 0x39
    1040              : // AVAILABLE: 0x3a
    1041              : 
    1042              : /**
    1043              :  *  @def CHIP_ERROR_INVALID_USE_OF_SESSION_KEY
    1044              :  *
    1045              :  *  @brief
    1046              :  *    A use of session key is invalid.
    1047              :  *
    1048              :  */
    1049              : #define CHIP_ERROR_INVALID_USE_OF_SESSION_KEY                  CHIP_CORE_ERROR(0x3b)
    1050              : 
    1051              : /**
    1052              :  *  @def CHIP_ERROR_CONNECTION_CLOSED_UNEXPECTEDLY
    1053              :  *
    1054              :  *  @brief
    1055              :  *    A connection is closed unexpectedly.
    1056              :  *
    1057              :  */
    1058              : #define CHIP_ERROR_CONNECTION_CLOSED_UNEXPECTEDLY              CHIP_CORE_ERROR(0x3c)
    1059              : 
    1060              : /**
    1061              :  *  @def CHIP_ERROR_MISSING_TLV_ELEMENT
    1062              :  *
    1063              :  *  @brief
    1064              :  *    A TLV element is missing.
    1065              :  *
    1066              :  */
    1067              : #define CHIP_ERROR_MISSING_TLV_ELEMENT                         CHIP_CORE_ERROR(0x3d)
    1068              : 
    1069              : /**
    1070              :  *  @def CHIP_ERROR_RANDOM_DATA_UNAVAILABLE
    1071              :  *
    1072              :  *  @brief
    1073              :  *    Secure random data is not available.
    1074              :  *
    1075              :  */
    1076              : #define CHIP_ERROR_RANDOM_DATA_UNAVAILABLE                     CHIP_CORE_ERROR(0x3e)
    1077              : 
    1078              : // AVAILABLE: 0x3f
    1079              : // AVAILABLE: 0x40
    1080              : 
    1081              : /**
    1082              :  *  @def CHIP_ERROR_HOST_PORT_LIST_EMPTY
    1083              :  *
    1084              :  *  @brief
    1085              :  *    A host/port list is empty.
    1086              :  *
    1087              :  */
    1088              : #define CHIP_ERROR_HOST_PORT_LIST_EMPTY                        CHIP_CORE_ERROR(0x41)
    1089              : 
    1090              : // AVAILABLE: 0x42
    1091              : // AVAILABLE: 0x43
    1092              : // AVAILABLE: 0x44
    1093              : 
    1094              : /**
    1095              :  *  @def CHIP_ERROR_FORCED_RESET
    1096              :  *
    1097              :  *  @brief
    1098              :  *    A service manager is forced to reset.
    1099              :  *
    1100              :  */
    1101              : #define CHIP_ERROR_FORCED_RESET                                CHIP_CORE_ERROR(0x45)
    1102              : 
    1103              : /**
    1104              :  *  @def CHIP_ERROR_NO_ENDPOINT
    1105              :  *
    1106              :  *  @brief
    1107              :  *    No endpoint is available.
    1108              :  *
    1109              :  */
    1110              : #define CHIP_ERROR_NO_ENDPOINT                                 CHIP_CORE_ERROR(0x46)
    1111              : 
    1112              : /**
    1113              :  *  @def CHIP_ERROR_INVALID_DESTINATION_NODE_ID
    1114              :  *
    1115              :  *  @brief
    1116              :  *    A destination node id is invalid.
    1117              :  *
    1118              :  */
    1119              : #define CHIP_ERROR_INVALID_DESTINATION_NODE_ID                 CHIP_CORE_ERROR(0x47)
    1120              : 
    1121              : /**
    1122              :  *  @def CHIP_ERROR_NOT_CONNECTED
    1123              :  *
    1124              :  *  @brief
    1125              :  *    The operation cannot be performed because the underlying object is not
    1126              :  *    connected.
    1127              :  *
    1128              :  */
    1129              : #define CHIP_ERROR_NOT_CONNECTED                               CHIP_CORE_ERROR(0x48)
    1130              : 
    1131              : // AVAILABLE: 0x49
    1132              : 
    1133              : /**
    1134              :  *  @def CHIP_ERROR_CA_CERT_NOT_FOUND
    1135              :  *
    1136              :  *  @brief
    1137              :  *    CA certificate is not found.
    1138              :  *
    1139              :  */
    1140              : #define CHIP_ERROR_CA_CERT_NOT_FOUND                           CHIP_CORE_ERROR(0x4a)
    1141              : 
    1142              : /**
    1143              :  *  @def CHIP_ERROR_CERT_PATH_LEN_CONSTRAINT_EXCEEDED
    1144              :  *
    1145              :  *  @brief
    1146              :  *    A certificate path length exceeds the constraint.
    1147              :  *
    1148              :  */
    1149              : #define CHIP_ERROR_CERT_PATH_LEN_CONSTRAINT_EXCEEDED           CHIP_CORE_ERROR(0x4b)
    1150              : 
    1151              : /**
    1152              :  *  @def CHIP_ERROR_CERT_PATH_TOO_LONG
    1153              :  *
    1154              :  *  @brief
    1155              :  *    A certificate path is too long.
    1156              :  *
    1157              :  */
    1158              : #define CHIP_ERROR_CERT_PATH_TOO_LONG                          CHIP_CORE_ERROR(0x4c)
    1159              : 
    1160              : /**
    1161              :  *  @def CHIP_ERROR_CERT_USAGE_NOT_ALLOWED
    1162              :  *
    1163              :  *  @brief
    1164              :  *    A requested certificate usage is not allowed.
    1165              :  *
    1166              :  */
    1167              : #define CHIP_ERROR_CERT_USAGE_NOT_ALLOWED                      CHIP_CORE_ERROR(0x4d)
    1168              : 
    1169              : /**
    1170              :  *  @def CHIP_ERROR_CERT_EXPIRED
    1171              :  *
    1172              :  *  @brief
    1173              :  *    A certificate expired.
    1174              :  *
    1175              :  */
    1176              : #define CHIP_ERROR_CERT_EXPIRED                                CHIP_CORE_ERROR(0x4e)
    1177              : 
    1178              : /**
    1179              :  *  @def CHIP_ERROR_CERT_NOT_VALID_YET
    1180              :  *
    1181              :  *  @brief
    1182              :  *    A certificate is not valid yet.
    1183              :  *
    1184              :  */
    1185              : #define CHIP_ERROR_CERT_NOT_VALID_YET                          CHIP_CORE_ERROR(0x4f)
    1186              : 
    1187              : /**
    1188              :  *  @def CHIP_ERROR_UNSUPPORTED_CERT_FORMAT
    1189              :  *
    1190              :  *  @brief
    1191              :  *    A certificate format is unsupported.
    1192              :  *
    1193              :  */
    1194              : #define CHIP_ERROR_UNSUPPORTED_CERT_FORMAT                     CHIP_CORE_ERROR(0x50)
    1195              : 
    1196              : /**
    1197              :  *  @def CHIP_ERROR_UNSUPPORTED_ELLIPTIC_CURVE
    1198              :  *
    1199              :  *  @brief
    1200              :  *    An elliptic curve is unsupported.
    1201              :  *
    1202              :  */
    1203              : #define CHIP_ERROR_UNSUPPORTED_ELLIPTIC_CURVE                  CHIP_CORE_ERROR(0x51)
    1204              : 
    1205              : // AVAILABLE: 0x52
    1206              : 
    1207              : /**
    1208              :  *  @def CHIP_ERROR_CERT_NOT_FOUND
    1209              :  *
    1210              :  *  @brief
    1211              :  *    A certificate is not found.
    1212              :  *
    1213              :  */
    1214              : #define CHIP_ERROR_CERT_NOT_FOUND                              CHIP_CORE_ERROR(0x53)
    1215              : 
    1216              : /**
    1217              :  *  @def CHIP_ERROR_INVALID_CASE_PARAMETER
    1218              :  *
    1219              :  *  @brief
    1220              :  *    A CASE parameter is invalid.
    1221              :  *
    1222              :  */
    1223              : #define CHIP_ERROR_INVALID_CASE_PARAMETER                      CHIP_CORE_ERROR(0x54)
    1224              : 
    1225              : // AVAILABLE: 0x55
    1226              : 
    1227              : /**
    1228              :  *  @def CHIP_ERROR_CERT_LOAD_FAILED
    1229              :  *
    1230              :  *  @brief
    1231              :  *    A certificate load failed.
    1232              :  *
    1233              :  */
    1234              : #define CHIP_ERROR_CERT_LOAD_FAILED                            CHIP_CORE_ERROR(0x56)
    1235              : 
    1236              : /**
    1237              :  *  @def CHIP_ERROR_CERT_NOT_TRUSTED
    1238              :  *
    1239              :  *  @brief
    1240              :  *    A certificate is not trusted.
    1241              :  *
    1242              :  */
    1243              : #define CHIP_ERROR_CERT_NOT_TRUSTED                            CHIP_CORE_ERROR(0x57)
    1244              : 
    1245              : // AVAILABLE: 0x58
    1246              : 
    1247              : /**
    1248              :  *  @def CHIP_ERROR_WRONG_CERT_DN
    1249              :  *
    1250              :  *  @brief
    1251              :  *    A certificate subject/issuer distinguished name is wrong.
    1252              :  *
    1253              :  */
    1254              : #define CHIP_ERROR_WRONG_CERT_DN                               CHIP_CORE_ERROR(0x59)
    1255              : 
    1256              : // AVAILABLE: 0x5a
    1257              : // AVAILABLE: 0x5b
    1258              : 
    1259              : /**
    1260              :  *  @def CHIP_ERROR_WRONG_NODE_ID
    1261              :  *
    1262              :  *  @brief
    1263              :  *    A node id is wrong.
    1264              :  *
    1265              :  */
    1266              : #define CHIP_ERROR_WRONG_NODE_ID                               CHIP_CORE_ERROR(0x5c)
    1267              : 
    1268              : // AVAILABLE: 0x5d
    1269              : // AVAILABLE: 0x5e
    1270              : // AVAILABLE: 0x5f
    1271              : // AVAILABLE: 0x60
    1272              : // AVAILABLE: 0x61
    1273              : // AVAILABLE: 0x62
    1274              : // AVAILABLE: 0x63
    1275              : 
    1276              : /**
    1277              :  *  @def CHIP_ERROR_RETRANS_TABLE_FULL
    1278              :  *
    1279              :  *  @brief
    1280              :  *    A retransmission table is already full.
    1281              :  *
    1282              :  */
    1283              : #define CHIP_ERROR_RETRANS_TABLE_FULL                          CHIP_CORE_ERROR(0x64)
    1284              : 
    1285              : // AVAILABLE: 0x65
    1286              : // AVAILABLE: 0x66
    1287              : // AVAILABLE: 0x67
    1288              : 
    1289              : /**
    1290              :  *  @def CHIP_ERROR_TRANSACTION_CANCELED
    1291              :  *
    1292              :  *  @brief
    1293              :  *    A transaction is cancelled.
    1294              :  *
    1295              :  */
    1296              : #define CHIP_ERROR_TRANSACTION_CANCELED                        CHIP_CORE_ERROR(0x68)
    1297              : 
    1298              : // AVAILABLE: 0x69
    1299              : // AVAILABLE: 0x6a
    1300              : 
    1301              : /**
    1302              :  *  @def CHIP_ERROR_INVALID_SUBSCRIPTION
    1303              :  *
    1304              :  *  @brief
    1305              :  *    A message was received as part of a subscription exchange that has a mis-matching subscription id.
    1306              :  *
    1307              :  */
    1308              : #define CHIP_ERROR_INVALID_SUBSCRIPTION                               CHIP_CORE_ERROR(0x6b)
    1309              : 
    1310              : /**
    1311              :  *  @def CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE
    1312              :  *
    1313              :  *  @brief
    1314              :  *    A CHIP feature is unsupported.
    1315              :  *
    1316              :  */
    1317              : #define CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE                    CHIP_CORE_ERROR(0x6c)
    1318              : 
    1319              : /**
    1320              :  *  @def CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR
    1321              :  *
    1322              :  *  @brief
    1323              :  *    An unsolicited message with the originator bit clear.
    1324              :  *
    1325              :  */
    1326              : #define CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR               CHIP_CORE_ERROR(0x70)
    1327              : 
    1328              : /**
    1329              :  *  @def CHIP_ERROR_INVALID_FABRIC_INDEX
    1330              :  *
    1331              :  *  @brief
    1332              :  *    A fabric index is invalid.
    1333              :  *
    1334              :  */
    1335              : #define CHIP_ERROR_INVALID_FABRIC_INDEX                        CHIP_CORE_ERROR(0x71)
    1336              : 
    1337              : /**
    1338              :  *  @def CHIP_ERROR_TOO_MANY_CONNECTIONS
    1339              :  *
    1340              :  *  @brief
    1341              :  *    The attempt to allocate a connection object failed because too many
    1342              :  *    connections exist.
    1343              :  *
    1344              :  */
    1345              : #define CHIP_ERROR_TOO_MANY_CONNECTIONS                        CHIP_CORE_ERROR(0x72)
    1346              : 
    1347              : /**
    1348              :  * @def CHIP_ERROR_SHUT_DOWN
    1349              :  *
    1350              :  * @brief
    1351              :  *   The operation cancelled because a shut down was initiated
    1352              :  */
    1353              : #define CHIP_ERROR_SHUT_DOWN                                   CHIP_CORE_ERROR(0x73)
    1354              : 
    1355              : /**
    1356              :  * @def CHIP_ERROR_CANCELLED
    1357              :  *
    1358              :  * @brief
    1359              :  *   The operation has been cancelled, generally by calling a cancel/abort request.
    1360              :  */
    1361              : #define CHIP_ERROR_CANCELLED                                   CHIP_CORE_ERROR(0x74)
    1362              : 
    1363              : // AVAILABLE: 0x75
    1364              : 
    1365              : /**
    1366              :  *  @def CHIP_ERROR_TLV_TAG_NOT_FOUND
    1367              :  *
    1368              :  *  @brief
    1369              :  *    A specified TLV tag was not found.
    1370              :  *
    1371              :  */
    1372              : #define CHIP_ERROR_TLV_TAG_NOT_FOUND                           CHIP_CORE_ERROR(0x76)
    1373              : 
    1374              : /**
    1375              :  * @def CHIP_ERROR_MISSING_SECURE_SESSION
    1376              :  *
    1377              :  * @brief
    1378              :  *
    1379              :  *  A secure session is needed to do work, but is missing/is not present.
    1380              :  */
    1381              : #define CHIP_ERROR_MISSING_SECURE_SESSION                      CHIP_CORE_ERROR(0x77)
    1382              : 
    1383              : /**
    1384              :  * @def CHIP_ERROR_INVALID_ADMIN_SUBJECT
    1385              :  *
    1386              :  * @brief
    1387              :  *   The CaseAdminSubject field is not valid in AddNOC command.
    1388              :  *
    1389              :  */
    1390              : #define CHIP_ERROR_INVALID_ADMIN_SUBJECT                      CHIP_CORE_ERROR(0x78)
    1391              : 
    1392              : /**
    1393              :  * @def CHIP_ERROR_INSUFFICIENT_PRIVILEGE
    1394              :  *
    1395              :  * @brief
    1396              :  *   Required privilege was insufficient during an operation.
    1397              :  *
    1398              :  */
    1399              : #define CHIP_ERROR_INSUFFICIENT_PRIVILEGE                          CHIP_CORE_ERROR(0x79)
    1400              : 
    1401              : // AVAILABLE: 0x7a
    1402              : // AVAILABLE: 0x7b
    1403              : // AVAILABLE: 0x7c
    1404              : 
    1405              : /**
    1406              :  * @def CHIP_ERROR_MESSAGE_COUNTER_EXHAUSTED
    1407              :  *
    1408              :  * @brief
    1409              :  *   The message counter of the session is exhausted, the session should be closed.
    1410              :  */
    1411              : #define CHIP_ERROR_MESSAGE_COUNTER_EXHAUSTED                 CHIP_CORE_ERROR(0x7d)
    1412              : 
    1413              : /**
    1414              :  *  @def CHIP_ERROR_FABRIC_EXISTS
    1415              :  *
    1416              :  *  @brief
    1417              :  *    The fabric with the given fabric id and root public key already exists.
    1418              :  *
    1419              :  */
    1420              : #define CHIP_ERROR_FABRIC_EXISTS                               CHIP_CORE_ERROR(0x7e)
    1421              : 
    1422              : /**
    1423              :  *  @def CHIP_ERROR_ENDPOINT_EXISTS
    1424              :  *
    1425              :  *  @brief
    1426              :  *    The endpoint with the given endpoint id already exists.
    1427              :  *
    1428              :  */
    1429              : #define CHIP_ERROR_ENDPOINT_EXISTS                               CHIP_CORE_ERROR(0x7f)
    1430              : 
    1431              : /**
    1432              :  *  @def CHIP_ERROR_WRONG_ENCRYPTION_TYPE_FROM_PEER
    1433              :  *
    1434              :  *  @brief
    1435              :  *    The wrong encryption type error received from a peer node.
    1436              :  *
    1437              :  */
    1438              : #define CHIP_ERROR_WRONG_ENCRYPTION_TYPE_FROM_PEER             CHIP_CORE_ERROR(0x80)
    1439              : 
    1440              : // AVAILABLE: 0x81
    1441              : // AVAILABLE: 0x82
    1442              : // AVAILABLE: 0x83
    1443              : // AVAILABLE: 0x84
    1444              : 
    1445              : /**
    1446              :  *  @def CHIP_ERROR_INVALID_KEY_ID
    1447              :  *
    1448              :  *  @brief
    1449              :  *    A key id is invalid.
    1450              :  *
    1451              :  */
    1452              : #define CHIP_ERROR_INVALID_KEY_ID                              CHIP_CORE_ERROR(0x85)
    1453              : 
    1454              : /**
    1455              :  *  @def CHIP_ERROR_INVALID_TIME
    1456              :  *
    1457              :  *  @brief
    1458              :  *    Time has invalid value.
    1459              :  *
    1460              :  */
    1461              : #define CHIP_ERROR_INVALID_TIME                                CHIP_CORE_ERROR(0x86)
    1462              : 
    1463              : // AVAILABLE: 0x87
    1464              : // AVAILABLE: 0x88
    1465              : // AVAILABLE: 0x89
    1466              : // AVAILABLE: 0x8a
    1467              : // AVAILABLE: 0x8b
    1468              : // AVAILABLE: 0x8c
    1469              : // AVAILABLE: 0x8d
    1470              : 
    1471              : /**
    1472              :  *  @def CHIP_ERROR_SCHEMA_MISMATCH
    1473              :  *
    1474              :  *  @brief
    1475              :  *    A mismatch in schema was encountered.
    1476              :  *
    1477              :  */
    1478              : #define CHIP_ERROR_SCHEMA_MISMATCH                             CHIP_CORE_ERROR(0x8e)
    1479              : 
    1480              : /**
    1481              :  *  @def CHIP_ERROR_INVALID_INTEGER_VALUE
    1482              :  *
    1483              :  *  @brief
    1484              :  *    An integer does not have the kind of value we expect.
    1485              :  *
    1486              :  */
    1487              : #define CHIP_ERROR_INVALID_INTEGER_VALUE                       CHIP_CORE_ERROR(0x8f)
    1488              : 
    1489              : // AVAILABLE: 0x90
    1490              : // AVAILABLE: 0x91
    1491              : 
    1492              : /**
    1493              :  *  @def CHIP_ERROR_BAD_REQUEST
    1494              :  *
    1495              :  *  @brief
    1496              :  *    The request cannot be processed or fulfilled
    1497              :  *
    1498              :  */
    1499              : #define CHIP_ERROR_BAD_REQUEST                                 CHIP_CORE_ERROR(0x92)
    1500              : 
    1501              : // AVAILABLE: 0x93
    1502              : // AVAILABLE: 0x94
    1503              : // AVAILABLE: 0x95
    1504              : // AVAILABLE: 0x96
    1505              : // AVAILABLE: 0x97
    1506              : // AVAILABLE: 0x98
    1507              : // AVAILABLE: 0x99
    1508              : // AVAILABLE: 0x9a
    1509              : // AVAILABLE: 0x9b
    1510              : // AVAILABLE: 0x9c
    1511              : 
    1512              : /**
    1513              :  * @def CHIP_ERROR_WRONG_CERT_TYPE
    1514              :  *
    1515              :  * @brief
    1516              :  *   The presented certificate was of the wrong type.
    1517              :  */
    1518              : #define CHIP_ERROR_WRONG_CERT_TYPE                             CHIP_CORE_ERROR(0x9d)
    1519              : 
    1520              : // AVAILABLE: 0x9e
    1521              : 
    1522              : /**
    1523              :  *  @def CHIP_ERROR_PERSISTED_STORAGE_FAILED
    1524              :  *
    1525              :  *  @brief
    1526              :  *    Persisted storage memory read/write failure.
    1527              :  *
    1528              :  */
    1529              : #define CHIP_ERROR_PERSISTED_STORAGE_FAILED                    CHIP_CORE_ERROR(0x9f)
    1530              : 
    1531              : /**
    1532              :  *  @def CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND
    1533              :  *
    1534              :  *  @brief
    1535              :  *    The specific value is not found in the persisted storage.
    1536              :  *
    1537              :  */
    1538              : #define CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND           CHIP_CORE_ERROR(0xa0)
    1539              : 
    1540              : /**
    1541              :  * @def CHIP_ERROR_IM_FABRIC_DELETED
    1542              :  *
    1543              :  * @brief
    1544              :  *   The fabric is deleted, and the corresponding IM resources are released
    1545              :  */
    1546              : #define CHIP_ERROR_IM_FABRIC_DELETED                            CHIP_CORE_ERROR(0xa1)
    1547              : 
    1548              : // AVAILABLE: 0xa2
    1549              : // AVAILABLE: 0xa3
    1550              : 
    1551              : /**
    1552              :  * @def CHIP_ERROR_IN_PROGRESS
    1553              :  *
    1554              :  * @brief
    1555              :  *   The operation is still in progress
    1556              :  */
    1557              : #define CHIP_ERROR_IN_PROGRESS                                 CHIP_CORE_ERROR(0xa4)
    1558              : 
    1559              : /**
    1560              :  *  @def CHIP_ERROR_ACCESS_DENIED
    1561              :  *
    1562              :  *  @brief
    1563              :  *    The CHIP message is not granted access for further processing.
    1564              :  */
    1565              : #define CHIP_ERROR_ACCESS_DENIED                               CHIP_CORE_ERROR(0xa5)
    1566              : 
    1567              : /**
    1568              :  *  @def CHIP_ERROR_UNKNOWN_RESOURCE_ID
    1569              :  *
    1570              :  *  @brief
    1571              :  *    Unknown resource ID
    1572              :  *
    1573              :  */
    1574              : #define CHIP_ERROR_UNKNOWN_RESOURCE_ID                         CHIP_CORE_ERROR(0xa6)
    1575              : 
    1576              : /**
    1577              :  * @def CHIP_ERROR_VERSION_MISMATCH
    1578              :  *
    1579              :  * @brief
    1580              :  *   The conditional update of a trait instance path has failed
    1581              :  *   because the local changes are based on an obsolete version of the
    1582              :  *   data.
    1583              :  */
    1584              : #define CHIP_ERROR_VERSION_MISMATCH                            CHIP_CORE_ERROR(0xa7)
    1585              : 
    1586              : /**
    1587              :  *  @def CHIP_ERROR_ACCESS_RESTRICTED_BY_ARL
    1588              :  *
    1589              :  *  @brief
    1590              :  *    The CHIP message is not granted access for further processing due to Access Restriction List.
    1591              :  */
    1592              : #define CHIP_ERROR_ACCESS_RESTRICTED_BY_ARL                    CHIP_CORE_ERROR(0xa8)
    1593              : 
    1594              : // AVAILABLE: 0xa9
    1595              : // AVAILABLE: 0xaa
    1596              : 
    1597              : /**
    1598              :  * @def CHIP_EVENT_ID_FOUND
    1599              :  *
    1600              :  * @brief
    1601              :  *   Event ID matching the criteria was found
    1602              :  */
    1603              : #define CHIP_ERROR_EVENT_ID_FOUND                              CHIP_CORE_ERROR(0xab)
    1604              : #define CHIP_EVENT_ID_FOUND CHIP_ERROR_EVENT_ID_FOUND
    1605              : 
    1606              : /**
    1607              :  * @def CHIP_ERROR_INTERNAL
    1608              :  *
    1609              :  * @brief
    1610              :  *   Internal error
    1611              :  */
    1612              : #define CHIP_ERROR_INTERNAL                                    CHIP_CORE_ERROR(0xac)
    1613              : 
    1614              : /**
    1615              :  * @def CHIP_ERROR_OPEN_FAILED
    1616              :  *
    1617              :  * @brief
    1618              :  *   Open file failed
    1619              :  */
    1620              : #define CHIP_ERROR_OPEN_FAILED                                 CHIP_CORE_ERROR(0xad)
    1621              : 
    1622              : /**
    1623              :  * @def CHIP_ERROR_READ_FAILED
    1624              :  *
    1625              :  * @brief
    1626              :  *   Read from file failed
    1627              :  */
    1628              : #define CHIP_ERROR_READ_FAILED                                 CHIP_CORE_ERROR(0xae)
    1629              : 
    1630              : /**
    1631              :  * @def CHIP_ERROR_WRITE_FAILED
    1632              :  *
    1633              :  * @brief
    1634              :  *   Write to file failed
    1635              :  */
    1636              : #define CHIP_ERROR_WRITE_FAILED                                CHIP_CORE_ERROR(0xaf)
    1637              : 
    1638              : /**
    1639              :  * @def CHIP_ERROR_DECODE_FAILED
    1640              :  *
    1641              :  * @brief
    1642              :  *   Decoding failed
    1643              :  */
    1644              : #define CHIP_ERROR_DECODE_FAILED                               CHIP_CORE_ERROR(0xb0)
    1645              : 
    1646              : // AVAILABLE: 0xb1
    1647              : // AVAILABLE: 0xb2
    1648              : 
    1649              : /**
    1650              :  *  @def CHIP_ERROR_DNS_SD_UNAUTHORIZED
    1651              :  *
    1652              :  *  @brief
    1653              :  *    The application is not authorized to do DNS_SD lookups.
    1654              :  *
    1655              :  */
    1656              : #define CHIP_ERROR_DNS_SD_UNAUTHORIZED                        CHIP_CORE_ERROR(0xb3)
    1657              : 
    1658              : /**
    1659              :  *  @def CHIP_ERROR_MDNS_COLLISION
    1660              :  *
    1661              :  *  @brief
    1662              :  *    The registered service name has collision on the LAN.
    1663              :  *
    1664              :  */
    1665              : #define CHIP_ERROR_MDNS_COLLISION                             CHIP_CORE_ERROR(0xb4)
    1666              : 
    1667              : /**
    1668              :  * @def CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB
    1669              :  *
    1670              :  * @brief
    1671              :  *   The Attribute path IB is malformed: it does not contain
    1672              :  *   the required path
    1673              :  */
    1674              : #define CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB                CHIP_CORE_ERROR(0xb5)
    1675              : 
    1676              : /**
    1677              :  * @def CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB
    1678              :  *
    1679              :  * @brief
    1680              :  *   The Event Path IB is malformed: it does not contain
    1681              :  *   the required elements
    1682              :  */
    1683              : #define CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB                     CHIP_CORE_ERROR(0xb6)
    1684              : 
    1685              : // AVAILABLE: 0xb7
    1686              : // AVAILABLE: 0xb8
    1687              : 
    1688              : /**
    1689              :  * @def CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_IB
    1690              :  *
    1691              :  * @brief
    1692              :  *   The Command Data IB is malformed: it does not contain
    1693              :  *   the required elements
    1694              :  */
    1695              : #define CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_IB           CHIP_CORE_ERROR(0xb9)
    1696              : 
    1697              : /**
    1698              :  * @def CHIP_ERROR_IM_MALFORMED_EVENT_DATA_IB
    1699              :  *
    1700              :  * @brief
    1701              :  *   The Event Data IB is malformed: it does not contain
    1702              :  *   the required elements
    1703              :  */
    1704              : #define CHIP_ERROR_IM_MALFORMED_EVENT_DATA_IB             CHIP_CORE_ERROR(0xba)
    1705              : 
    1706              : /**
    1707              :  * @def CHIP_ERROR_MAXIMUM_PATHS_PER_INVOKE_EXCEEDED
    1708              :  *
    1709              :  * @brief
    1710              :  *   Caller is trying to add more invoke command paths
    1711              :  *   than what the remote node reports supporting.
    1712              :  */
    1713              : #define CHIP_ERROR_MAXIMUM_PATHS_PER_INVOKE_EXCEEDED           CHIP_CORE_ERROR(0xbb)
    1714              : 
    1715              : /**
    1716              :  * @def CHIP_ERROR_PEER_NODE_NOT_FOUND
    1717              :  *
    1718              :  * @brief
    1719              :  *   Unable to find the peer node
    1720              :  */
    1721              : #define CHIP_ERROR_PEER_NODE_NOT_FOUND                         CHIP_CORE_ERROR(0xbc)
    1722              : 
    1723              : /**
    1724              :  * @def CHIP_ERROR_HSM
    1725              :  *
    1726              :  * @brief
    1727              :  *   Error in Hardware security module. Used for software fallback option.
    1728              :  */
    1729              : #define CHIP_ERROR_HSM                                         CHIP_CORE_ERROR(0xbd)
    1730              : 
    1731              : // AVAILABLE: 0xbe
    1732              : 
    1733              : /**
    1734              :  *  @def CHIP_ERROR_REAL_TIME_NOT_SYNCED
    1735              :  *
    1736              :  *  @brief
    1737              :  *      The system's real time clock is not synchronized to an accurate time source.
    1738              :  */
    1739              : #define CHIP_ERROR_REAL_TIME_NOT_SYNCED                        CHIP_CORE_ERROR(0xbf)
    1740              : 
    1741              : /**
    1742              :  *  @def CHIP_ERROR_UNEXPECTED_EVENT
    1743              :  *
    1744              :  *  @brief
    1745              :  *      An unexpected event was encountered.
    1746              :  */
    1747              : #define CHIP_ERROR_UNEXPECTED_EVENT                            CHIP_CORE_ERROR(0xc0)
    1748              : 
    1749              : /**
    1750              :  *  @def CHIP_ERROR_ENDPOINT_POOL_FULL
    1751              :  *
    1752              :  *  @brief
    1753              :  *    No endpoint pool entry is available.
    1754              :  *
    1755              :  */
    1756              : #define CHIP_ERROR_ENDPOINT_POOL_FULL                          CHIP_CORE_ERROR(0xc1)
    1757              : 
    1758              : /**
    1759              :  *  @def CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG
    1760              :  *
    1761              :  *  @brief
    1762              :  *    More inbound message data is pending than available buffer space available to copy it.
    1763              :  *
    1764              :  */
    1765              : #define CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG                     CHIP_CORE_ERROR(0xc2)
    1766              : 
    1767              : /**
    1768              :  *  @def CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG
    1769              :  *
    1770              :  *  @brief
    1771              :  *    More outbound message data is pending than available buffer space available to copy it.
    1772              :  *
    1773              :  */
    1774              : #define CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG                    CHIP_CORE_ERROR(0xc3)
    1775              : 
    1776              : /**
    1777              :  * @def CHIP_ERROR_DUPLICATE_MESSAGE_RECEIVED
    1778              :  *
    1779              :  * @brief
    1780              :  *   The received message is a duplicate of a previously received message.
    1781              :  */
    1782              : #define CHIP_ERROR_DUPLICATE_MESSAGE_RECEIVED                  CHIP_CORE_ERROR(0xc4)
    1783              : 
    1784              : /**
    1785              :  * @def CHIP_ERROR_INVALID_PUBLIC_KEY
    1786              :  *
    1787              :  * @brief
    1788              :  *   The received public key doesn't match locally generated key.
    1789              :  */
    1790              : #define CHIP_ERROR_INVALID_PUBLIC_KEY                          CHIP_CORE_ERROR(0xc5)
    1791              : 
    1792              : /**
    1793              :  * @def CHIP_ERROR_FABRIC_MISMATCH_ON_ICA
    1794              :  *
    1795              :  * @brief
    1796              :  *   The fabric ID in ICA certificate doesn't match the one in NOC.
    1797              :  */
    1798              : #define CHIP_ERROR_FABRIC_MISMATCH_ON_ICA                      CHIP_CORE_ERROR(0xc6)
    1799              : 
    1800              : // AVAILABLE: 0xc7
    1801              : // AVAILABLE: 0xc8
    1802              : 
    1803              : /**
    1804              :  * @def CHIP_ERROR_NO_SHARED_TRUSTED_ROOT
    1805              :  *
    1806              :  * @brief
    1807              :  *   The CASE session could not be established as peer's credentials do not have
    1808              :  *   a common root of trust.
    1809              :  */
    1810              : #define CHIP_ERROR_NO_SHARED_TRUSTED_ROOT                      CHIP_CORE_ERROR(0xc9)
    1811              : 
    1812              : /*
    1813              :  * @def CHIP_ERROR_IM_STATUS_CODE_RECEIVED
    1814              :  *
    1815              :  * @brief
    1816              :  *   Indicates an IM status code was received. Usually accompanied with
    1817              :  *   the actual IM status code.
    1818              :  */
    1819              : #define CHIP_ERROR_IM_STATUS_CODE_RECEIVED                     CHIP_CORE_ERROR(0xca)
    1820              : 
    1821              : // AVAILABLE 0xcb
    1822              : // AVAILABLE 0xcc
    1823              : // AVAILABLE 0xcd
    1824              : // AVAILABLE 0xce
    1825              : // AVAILABLE 0xcf
    1826              : // AVAILABLE 0xd0
    1827              : // AVAILABLE 0xd1
    1828              : // AVAILABLE 0xd2
    1829              : // AVAILABLE 0xd3
    1830              : // AVAILABLE 0xd4
    1831              : // AVAILABLE 0xd5
    1832              : // AVAILABLE 0xd6
    1833              : 
    1834              : /**
    1835              :  * @def CHIP_ERROR_IM_MALFORMED_DATA_VERSION_FILTER_IB
    1836              :  *
    1837              :  * @brief
    1838              :  *   The Data Version Filter IB is malformed: it does not contain
    1839              :  *   the required elements
    1840              :  */
    1841              : #define CHIP_ERROR_IM_MALFORMED_DATA_VERSION_FILTER_IB             CHIP_CORE_ERROR(0xd7)
    1842              : 
    1843              : /**
    1844              :  * @def CHIP_ERROR_NOT_FOUND
    1845              :  *
    1846              :  * @brief
    1847              :  *   The item referenced in the function call was not found
    1848              :  */
    1849              : #define CHIP_ERROR_NOT_FOUND                                       CHIP_CORE_ERROR(0xd8)
    1850              : 
    1851              : // AVAILABLE: 0xd9
    1852              : 
    1853              : /**
    1854              :  * @def CHIP_ERROR_INVALID_FILE_IDENTIFIER
    1855              :  *
    1856              :  * @brief
    1857              :  *   The file identifier, encoded in the first few bytes of a processed file,
    1858              :  *   has unexpected value.
    1859              :  */
    1860              : #define CHIP_ERROR_INVALID_FILE_IDENTIFIER                     CHIP_CORE_ERROR(0xda)
    1861              : 
    1862              : /**
    1863              :  * @def CHIP_ERROR_BUSY
    1864              :  *
    1865              :  * @brief
    1866              :  *   The Resource is busy and cannot process the request. Trying again might work.
    1867              :  */
    1868              : #define CHIP_ERROR_BUSY                                        CHIP_CORE_ERROR(0xdb)
    1869              : 
    1870              : /**
    1871              :   * @def CHIP_ERROR_MAX_RETRY_EXCEEDED
    1872              :   *
    1873              :   * @brief
    1874              :   *   The maximum retry limit has been exceeded.
    1875              :   */
    1876              :  #define CHIP_ERROR_MAX_RETRY_EXCEEDED                         CHIP_CORE_ERROR(0xdc)
    1877              : 
    1878              :  /**
    1879              :   * @def CHIP_ERROR_PROVIDER_LIST_EXHAUSTED
    1880              :   *
    1881              :   * @brief
    1882              :   *   The provider list has been exhausted.
    1883              :   */
    1884              :  #define CHIP_ERROR_PROVIDER_LIST_EXHAUSTED                    CHIP_CORE_ERROR(0xdd)
    1885              : 
    1886              : // AVAILABLE: 0xde
    1887              : 
    1888              : /**
    1889              :  * @def CHIP_ERROR_INVALID_SCHEME_PREFIX
    1890              :  *
    1891              :  * @brief
    1892              :  *   The scheme field contains an invalid prefix
    1893              :  */
    1894              : #define CHIP_ERROR_INVALID_SCHEME_PREFIX                      CHIP_CORE_ERROR(0xdf)
    1895              : 
    1896              : /**
    1897              :  * @def CHIP_ERROR_MISSING_URI_SEPARATOR
    1898              :  *
    1899              :  * @brief
    1900              :  *   The URI separator is missing
    1901              :  */
    1902              : #define CHIP_ERROR_MISSING_URI_SEPARATOR                      CHIP_CORE_ERROR(0xe0)
    1903              : 
    1904              : /**
    1905              :  * @def CHIP_ERROR_HANDLER_NOT_SET
    1906              :  *
    1907              :  * @brief
    1908              :  *   Callback function or callable object is not set
    1909              :  */
    1910              : #define CHIP_ERROR_HANDLER_NOT_SET                            CHIP_CORE_ERROR(0xe1)
    1911              : 
    1912              : // WHEN ADDING A NEW ERROR CODE: Look for "AVAILABLE" comments above and fill in gaps.
    1913              : 
    1914              : // clang-format on
    1915              : 
    1916              : // !!!!! IMPORTANT !!!!!  If you add new CHIP errors, please update the translation
    1917              : // of error codes to strings in CHIPError.cpp, and add them to kTestElements[]
    1918              : // in core/tests/TestCHIPErrorStr.cpp
    1919              : 
    1920              : // Prior to ChipError being marked [[nodiscard]], there were numerous places
    1921              : // where the return value was ignored.
    1922              : // This grandfathers those usages.
    1923              : // NEW CODE SHOULD NOT USE THIS
    1924              : #define TEMPORARY_RETURN_IGNORED (void)
    1925              : 
    1926              : // Explicitly ignores a ChipError returned from a method, if a failure can be safely ignored.
    1927              : // USE WITH EXTREME CAUTION
    1928              : // LogOnFailure may be a better approach
    1929              : #define RETURN_SAFELY_IGNORED (void)
    1930              : 
    1931              : namespace chip {
    1932              : 
    1933              : extern void RegisterCHIPLayerErrorFormatter();
    1934              : extern void DeregisterCHIPLayerErrorFormatter();
    1935              : extern bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err);
    1936              : 
    1937              : __attribute__((always_inline)) inline ChipError ChipError::NoErrorIf(ChipError suppressed)
    1938              : {
    1939          772 :     return (*this == suppressed) ? CHIP_NO_ERROR : *this;
    1940              : }
    1941              : } // namespace chip
        

Generated by: LCOV version 2.0-1