Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / lib / core / CHIPError.cpp
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2019 Google LLC.
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 contains functions for working with CHIP errors.
22  */
23
24 #include <stddef.h>
25
26 #include <core/CHIPCore.h>
27 #include <support/ErrorStr.h>
28
29 namespace chip {
30
31 /**
32  * Register a text error formatter for CHIP core errors.
33  */
34 void RegisterCHIPLayerErrorFormatter()
35 {
36     static ErrorFormatter sCHIPErrorFormatter = { FormatCHIPError, nullptr };
37
38     RegisterErrorFormatter(&sCHIPErrorFormatter);
39 }
40
41 /**
42  * Given a CHIP error, returns a human-readable NULL-terminated C string
43  * describing the error.
44  *
45  * @param[in] buf                   Buffer into which the error string will be placed.
46  * @param[in] bufSize               Size of the supplied buffer in bytes.
47  * @param[in] err                   The error to be described.
48  *
49  * @return true                     If a description string was written into the supplied buffer.
50  * @return false                    If the supplied error was not a CHIP error.
51  *
52  */
53 bool FormatCHIPError(char * buf, uint16_t bufSize, int32_t err)
54 {
55     const char * desc = nullptr;
56
57     if (err < CHIP_ERROR_MIN || err > CHIP_ERROR_MAX)
58     {
59         return false;
60     }
61
62 #if !CHIP_CONFIG_SHORT_ERROR_STR
63     switch (err)
64     {
65     case CHIP_ERROR_TOO_MANY_CONNECTIONS:
66         desc = "Too many connections";
67         break;
68     case CHIP_ERROR_SENDING_BLOCKED:
69         desc = "Sending blocked";
70         break;
71     case CHIP_ERROR_CONNECTION_ABORTED:
72         desc = "Connection aborted";
73         break;
74     case CHIP_ERROR_INCORRECT_STATE:
75         desc = "Incorrect state";
76         break;
77     case CHIP_ERROR_MESSAGE_TOO_LONG:
78         desc = "Message too long";
79         break;
80     case CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION:
81         desc = "Unsupported exchange version";
82         break;
83     case CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS:
84         desc = "Too many unsolicited message handlers";
85         break;
86     case CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER:
87         desc = "No unsolicited message handler";
88         break;
89     case CHIP_ERROR_NO_CONNECTION_HANDLER:
90         desc = "No connection handler";
91         break;
92     case CHIP_ERROR_TOO_MANY_PEER_NODES:
93         desc = "Too many peer nodes";
94         break;
95     case CHIP_ERROR_NO_MEMORY:
96         desc = "No memory";
97         break;
98     case CHIP_ERROR_NO_MESSAGE_HANDLER:
99         desc = "No message handler";
100         break;
101     case CHIP_ERROR_MESSAGE_INCOMPLETE:
102         desc = "Message incomplete";
103         break;
104     case CHIP_ERROR_DATA_NOT_ALIGNED:
105         desc = "Data not aligned";
106         break;
107     case CHIP_ERROR_UNKNOWN_KEY_TYPE:
108         desc = "Unknown key type";
109         break;
110     case CHIP_ERROR_KEY_NOT_FOUND:
111         desc = "Key not found";
112         break;
113     case CHIP_ERROR_WRONG_ENCRYPTION_TYPE:
114         desc = "Wrong encryption type";
115         break;
116     case CHIP_ERROR_TOO_MANY_KEYS:
117         desc = "Too many keys";
118         break;
119     case CHIP_ERROR_INTEGRITY_CHECK_FAILED:
120         desc = "Integrity check failed";
121         break;
122     case CHIP_ERROR_INVALID_SIGNATURE:
123         desc = "Invalid signature";
124         break;
125     case CHIP_ERROR_UNSUPPORTED_MESSAGE_VERSION:
126         desc = "Unsupported message version";
127         break;
128     case CHIP_ERROR_UNSUPPORTED_ENCRYPTION_TYPE:
129         desc = "Unsupported encryption type";
130         break;
131     case CHIP_ERROR_UNSUPPORTED_SIGNATURE_TYPE:
132         desc = "Unsupported signature type";
133         break;
134     case CHIP_ERROR_INVALID_MESSAGE_LENGTH:
135         desc = "Invalid message length";
136         break;
137     case CHIP_ERROR_BUFFER_TOO_SMALL:
138         desc = "Buffer too small";
139         break;
140     case CHIP_ERROR_DUPLICATE_KEY_ID:
141         desc = "Duplicate key id";
142         break;
143     case CHIP_ERROR_WRONG_KEY_TYPE:
144         desc = "Wrong key type";
145         break;
146     case CHIP_ERROR_WELL_UNINITIALIZED:
147         desc = "Well uninitialized";
148         break;
149     case CHIP_ERROR_WELL_EMPTY:
150         desc = "Well empty";
151         break;
152     case CHIP_ERROR_INVALID_STRING_LENGTH:
153         desc = "Invalid string length";
154         break;
155     case CHIP_ERROR_INVALID_LIST_LENGTH:
156         desc = "invalid list length";
157         break;
158     case CHIP_ERROR_INVALID_INTEGRITY_TYPE:
159         desc = "Invalid integrity type";
160         break;
161     case CHIP_END_OF_TLV:
162         desc = "End of TLV";
163         break;
164     case CHIP_ERROR_TLV_UNDERRUN:
165         desc = "TLV underrun";
166         break;
167     case CHIP_ERROR_INVALID_TLV_ELEMENT:
168         desc = "Invalid TLV element";
169         break;
170     case CHIP_ERROR_INVALID_TLV_TAG:
171         desc = "Invalid TLV tag";
172         break;
173     case CHIP_ERROR_UNKNOWN_IMPLICIT_TLV_TAG:
174         desc = "Unknown implicit TLV tag";
175         break;
176     case CHIP_ERROR_WRONG_TLV_TYPE:
177         desc = "Wrong TLV type";
178         break;
179     case CHIP_ERROR_TLV_CONTAINER_OPEN:
180         desc = "TLV container open";
181         break;
182     case CHIP_ERROR_INVALID_TRANSFER_MODE:
183         desc = "Invalid transfer mode";
184         break;
185     case CHIP_ERROR_INVALID_PROFILE_ID:
186         desc = "Invalid profile id";
187         break;
188     case CHIP_ERROR_INVALID_MESSAGE_TYPE:
189         desc = "Invalid message type";
190         break;
191     case CHIP_ERROR_UNEXPECTED_TLV_ELEMENT:
192         desc = "Unexpected TLV element";
193         break;
194     case CHIP_ERROR_STATUS_REPORT_RECEIVED:
195         desc = "Status Report received from peer";
196         break;
197     case CHIP_ERROR_NOT_IMPLEMENTED:
198         desc = "Not Implemented";
199         break;
200     case CHIP_ERROR_INVALID_ADDRESS:
201         desc = "Invalid address";
202         break;
203     case CHIP_ERROR_INVALID_ARGUMENT:
204         desc = "Invalid argument";
205         break;
206     case CHIP_ERROR_TLV_TAG_NOT_FOUND:
207         desc = "TLV tag not found";
208         break;
209
210     case CHIP_ERROR_INVALID_PATH_LIST:
211         desc = "Invalid TLV path list";
212         break;
213     case CHIP_ERROR_INVALID_DATA_LIST:
214         desc = "Invalid TLV data list";
215         break;
216     case CHIP_ERROR_TRANSACTION_CANCELED:
217         desc = "Transaction canceled";
218         break;
219     case CHIP_ERROR_LISTENER_ALREADY_STARTED:
220         desc = "Listener already started";
221         break;
222     case CHIP_ERROR_LISTENER_ALREADY_STOPPED:
223         desc = "Listener already stopped";
224         break;
225     case CHIP_ERROR_UNKNOWN_TOPIC:
226         desc = "Unknown Topic";
227         break;
228     case CHIP_ERROR_TIMEOUT:
229         desc = "Timeout";
230         break;
231     case CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR:
232         desc = "Invalid device descriptor";
233         break;
234     case CHIP_ERROR_UNSUPPORTED_DEVICE_DESCRIPTOR_VERSION:
235         desc = "Unsupported device descriptor version";
236         break;
237     case CHIP_END_OF_INPUT:
238         desc = "End of input";
239         break;
240     case CHIP_ERROR_RATE_LIMIT_EXCEEDED:
241         desc = "Rate limit exceeded";
242         break;
243     case CHIP_ERROR_SECURITY_MANAGER_BUSY:
244         desc = "Security manager busy";
245         break;
246     case CHIP_ERROR_INVALID_PASE_PARAMETER:
247         desc = "Invalid PASE parameter";
248         break;
249     case CHIP_ERROR_PASE_SUPPORTS_ONLY_CONFIG1:
250         desc = "PASE supports only Config1";
251         break;
252     case CHIP_ERROR_NO_COMMON_PASE_CONFIGURATIONS:
253         desc = "No supported PASE configurations in common";
254         break;
255     case CHIP_ERROR_INVALID_PASE_CONFIGURATION:
256         desc = "Invalid PASE configuration";
257         break;
258     case CHIP_ERROR_KEY_CONFIRMATION_FAILED:
259         desc = "Key confirmation failed";
260         break;
261     case CHIP_ERROR_INVALID_USE_OF_SESSION_KEY:
262         desc = "Invalid use of session key";
263         break;
264     case CHIP_ERROR_CONNECTION_CLOSED_UNEXPECTEDLY:
265         desc = "Connection closed unexpectedly";
266         break;
267     case CHIP_ERROR_MISSING_TLV_ELEMENT:
268         desc = "Missing TLV element";
269         break;
270     case CHIP_ERROR_RANDOM_DATA_UNAVAILABLE:
271         desc = "Random data unavailable";
272         break;
273     case CHIP_ERROR_UNSUPPORTED_HOST_PORT_ELEMENT:
274         desc = "Unsupported type in host/port list";
275         break;
276     case CHIP_ERROR_INVALID_HOST_SUFFIX_INDEX:
277         desc = "Invalid suffix index in host/port list";
278         break;
279     case CHIP_ERROR_HOST_PORT_LIST_EMPTY:
280         desc = "Host/port empty";
281         break;
282     case CHIP_ERROR_UNSUPPORTED_AUTH_MODE:
283         desc = "Unsupported authentication mode";
284         break;
285     case CHIP_ERROR_INVALID_SERVICE_EP:
286         desc = "Invalid service endpoint";
287         break;
288     case CHIP_ERROR_INVALID_DIRECTORY_ENTRY_TYPE:
289         desc = "Invalid directory entry type";
290         break;
291     case CHIP_ERROR_FORCED_RESET:
292         desc = "Service manager forced reset";
293         break;
294     case CHIP_ERROR_NO_ENDPOINT:
295         desc = "No endpoint was available to send the message";
296         break;
297     case CHIP_ERROR_INVALID_DESTINATION_NODE_ID:
298         desc = "Invalid destination node id";
299         break;
300     case CHIP_ERROR_NOT_CONNECTED:
301         desc = "Not connected";
302         break;
303     case CHIP_ERROR_NO_SW_UPDATE_AVAILABLE:
304         desc = "No SW update available";
305         break;
306     case CHIP_ERROR_CA_CERT_NOT_FOUND:
307         desc = "CA certificate not found";
308         break;
309     case CHIP_ERROR_CERT_PATH_LEN_CONSTRAINT_EXCEEDED:
310         desc = "Certificate path length constraint exceeded";
311         break;
312     case CHIP_ERROR_CERT_PATH_TOO_LONG:
313         desc = "Certificate path too long";
314         break;
315     case CHIP_ERROR_CERT_USAGE_NOT_ALLOWED:
316         desc = "Requested certificate usage is not allowed";
317         break;
318     case CHIP_ERROR_CERT_EXPIRED:
319         desc = "Certificate expired";
320         break;
321     case CHIP_ERROR_CERT_NOT_VALID_YET:
322         desc = "Certificate not yet valid";
323         break;
324     case CHIP_ERROR_UNSUPPORTED_CERT_FORMAT:
325         desc = "Unsupported certificate format";
326         break;
327     case CHIP_ERROR_UNSUPPORTED_ELLIPTIC_CURVE:
328         desc = "Unsupported elliptic curve";
329         break;
330     case CHIP_CERT_NOT_USED:
331         desc = "Certificate was not used in chain validation";
332         break;
333     case CHIP_ERROR_CERT_NOT_FOUND:
334         desc = "Certificate not found";
335         break;
336     case CHIP_ERROR_INVALID_CASE_PARAMETER:
337         desc = "Invalid CASE parameter";
338         break;
339     case CHIP_ERROR_UNSUPPORTED_CASE_CONFIGURATION:
340         desc = "Unsupported CASE configuration";
341         break;
342     case CHIP_ERROR_CERT_LOAD_FAILED:
343         desc = "Unable to load certificate";
344         break;
345     case CHIP_ERROR_CERT_NOT_TRUSTED:
346         desc = "Certificate not trusted";
347         break;
348     case CHIP_ERROR_INVALID_ACCESS_TOKEN:
349         desc = "Invalid access token";
350         break;
351     case CHIP_ERROR_WRONG_CERT_SUBJECT:
352         desc = "Wrong certificate subject";
353         break;
354     case CHIP_ERROR_INVALID_PROVISIONING_BUNDLE:
355         desc = "Invalid provisioning bundle";
356         break;
357     case CHIP_ERROR_PROVISIONING_BUNDLE_DECRYPTION_ERROR:
358         desc = "Provisioning bundle decryption error";
359         break;
360     case CHIP_ERROR_PASE_RECONFIGURE_REQUIRED:
361         desc = "PASE reconfiguration required";
362         break;
363     case CHIP_ERROR_WRONG_NODE_ID:
364         desc = "Wrong node ID";
365         break;
366     case CHIP_ERROR_CONN_ACCEPTED_ON_WRONG_PORT:
367         desc = "Connection accepted on wrong port";
368         break;
369     case CHIP_ERROR_CALLBACK_REPLACED:
370         desc = "Application callback replaced";
371         break;
372     case CHIP_ERROR_NO_CASE_AUTH_DELEGATE:
373         desc = "No CASE auth delegate set";
374         break;
375     case CHIP_ERROR_DEVICE_LOCATE_TIMEOUT:
376         desc = "Timeout attempting to locate device";
377         break;
378     case CHIP_ERROR_DEVICE_CONNECT_TIMEOUT:
379         desc = "Timeout connecting to device";
380         break;
381     case CHIP_ERROR_DEVICE_AUTH_TIMEOUT:
382         desc = "Timeout authenticating device";
383         break;
384     case CHIP_ERROR_MESSAGE_NOT_ACKNOWLEDGED:
385         desc = "Message not acknowledged after max retries";
386         break;
387     case CHIP_ERROR_RETRANS_TABLE_FULL:
388         desc = "Retransmit Table is already full";
389         break;
390     case CHIP_ERROR_INVALID_ACK_ID:
391         desc = "Invalid Acknowledgment Id";
392         break;
393     case CHIP_ERROR_SEND_THROTTLED:
394         desc = "Sending to peer is throttled on this Exchange";
395         break;
396     case CHIP_ERROR_WRONG_MSG_VERSION_FOR_EXCHANGE:
397         desc = "Message version not supported by current exchange context";
398         break;
399     case CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE:
400         desc = "Required feature not supported by this configuration";
401         break;
402     case CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR:
403         desc = "Unsolicited msg with originator bit clear";
404         break;
405     case CHIP_ERROR_INVALID_FABRIC_ID:
406         desc = "Invalid Fabric Id";
407         break;
408     case CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED:
409         desc = "DRBG entropy source failed to generate entropy data";
410         break;
411     case CHIP_ERROR_NO_TAKE_AUTH_DELEGATE:
412         desc = "No TAKE auth delegate set";
413         break;
414     case CHIP_ERROR_TAKE_RECONFIGURE_REQUIRED:
415         desc = "TAKE requires a reconfigure";
416         break;
417     case CHIP_ERROR_TAKE_REAUTH_POSSIBLE:
418         desc = "TAKE can do a reauthentication";
419         break;
420     case CHIP_ERROR_INVALID_TAKE_PARAMETER:
421         desc = "TAKE received an invalid parameter";
422         break;
423     case CHIP_ERROR_UNSUPPORTED_TAKE_CONFIGURATION:
424         desc = "TAKE Unsupported configuration";
425         break;
426     case CHIP_ERROR_TAKE_TOKEN_IDENTIFICATION_FAILED:
427         desc = "TAKE token identification failed";
428         break;
429     case CHIP_ERROR_INVALID_TOKENPAIRINGBUNDLE:
430         desc = "Invalid Token Pairing Bundle";
431         break;
432     case CHIP_ERROR_UNSUPPORTED_TOKENPAIRINGBUNDLE_VERSION:
433         desc = "Unsupported Token Pairing Bundle version";
434         break;
435     case CHIP_ERROR_KEY_NOT_FOUND_FROM_PEER:
436         desc = "Key not found error code received from peer";
437         break;
438     case CHIP_ERROR_WRONG_ENCRYPTION_TYPE_FROM_PEER:
439         desc = "Wrong encryption type error code received from peer";
440         break;
441     case CHIP_ERROR_UNKNOWN_KEY_TYPE_FROM_PEER:
442         desc = "Unknown key type error code received from peer";
443         break;
444     case CHIP_ERROR_INVALID_USE_OF_SESSION_KEY_FROM_PEER:
445         desc = "Invalid use of session key error code received from peer";
446         break;
447     case CHIP_ERROR_UNSUPPORTED_ENCRYPTION_TYPE_FROM_PEER:
448         desc = "Unsupported encryption type error code received from peer";
449         break;
450     case CHIP_ERROR_INTERNAL_KEY_ERROR_FROM_PEER:
451         desc = "Internal key error code received from peer";
452         break;
453     case CHIP_ERROR_INVALID_KEY_ID:
454         desc = "Invalid key identifier";
455         break;
456     case CHIP_ERROR_INVALID_TIME:
457         desc = "Valid time value is not available";
458         break;
459     case CHIP_ERROR_LOCKING_FAILURE:
460         desc = "Failure to lock/unlock OS-provided lock";
461         break;
462     case CHIP_ERROR_UNSUPPORTED_PASSCODE_CONFIG:
463         desc = "Unsupported passcode encryption configuration";
464         break;
465     case CHIP_ERROR_PASSCODE_AUTHENTICATION_FAILED:
466         desc = "Passcode authentication failed";
467         break;
468     case CHIP_ERROR_PASSCODE_FINGERPRINT_FAILED:
469         desc = "Passcode fingerprint failed";
470         break;
471     case CHIP_ERROR_SERIALIZATION_ELEMENT_NULL:
472         desc = "Element requested is null";
473         break;
474     case CHIP_ERROR_WRONG_CERT_SIGNATURE_ALGORITHM:
475         desc = "Certificate not signed with required signature algorithm";
476         break;
477     case CHIP_ERROR_WRONG_CHIP_SIGNATURE_ALGORITHM:
478         desc = "CHIP signature not signed with required signature algorithm";
479         break;
480     case CHIP_ERROR_SCHEMA_MISMATCH:
481         desc = "Schema mismatch";
482         break;
483     case CHIP_ERROR_INVALID_INTEGER_VALUE:
484         desc = "Invalid integer value";
485         break;
486     case CHIP_ERROR_CASE_RECONFIG_REQUIRED:
487         desc = "CASE reconfiguration required";
488         break;
489     case CHIP_ERROR_TOO_MANY_CASE_RECONFIGURATIONS:
490         desc = "Too many CASE reconfigurations were received";
491         break;
492     case CHIP_ERROR_BAD_REQUEST:
493         desc = "Request cannot be processed or fulfilled";
494         break;
495     case CHIP_ERROR_INVALID_MESSAGE_FLAG:
496         desc = "Invalid message flag";
497         break;
498     case CHIP_ERROR_KEY_EXPORT_RECONFIGURE_REQUIRED:
499         desc = "Key export protocol required to reconfigure";
500         break;
501     case CHIP_ERROR_NO_COMMON_KEY_EXPORT_CONFIGURATIONS:
502         desc = "No supported key export protocol configurations in common";
503         break;
504     case CHIP_ERROR_INVALID_KEY_EXPORT_CONFIGURATION:
505         desc = "Invalid key export protocol configuration";
506         break;
507     case CHIP_ERROR_NO_KEY_EXPORT_DELEGATE:
508         desc = "No key export protocol delegate set";
509         break;
510     case CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_REQUEST:
511         desc = "Unauthorized key export request";
512         break;
513     case CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_RESPONSE:
514         desc = "Unauthorized key export response";
515         break;
516     case CHIP_ERROR_EXPORTED_KEY_AUTHENTICATION_FAILED:
517         desc = "Exported key authentication failed";
518         break;
519     case CHIP_ERROR_TOO_MANY_SHARED_SESSION_END_NODES:
520         desc = "Too many shared session end nodes";
521         break;
522     case CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_DATA_ELEMENT:
523         desc = "Malformed Interaction Model Attribute DataElement";
524         break;
525     case CHIP_ERROR_WRONG_CERT_TYPE:
526         desc = "Wrong certificate type";
527         break;
528     case CHIP_ERROR_DEFAULT_EVENT_HANDLER_NOT_CALLED:
529         desc = "Default event handler not called";
530         break;
531     case CHIP_ERROR_PERSISTED_STORAGE_FAILED:
532         desc = "Persisted storage failed";
533         break;
534     case CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND:
535         desc = "Value not found in the persisted storage";
536         break;
537     case CHIP_ERROR_PROFILE_STRING_CONTEXT_ALREADY_REGISTERED:
538         desc = "String context already registered";
539         break;
540     case CHIP_ERROR_PROFILE_STRING_CONTEXT_NOT_REGISTERED:
541         desc = "String context not registered";
542         break;
543     case CHIP_ERROR_INCOMPATIBLE_SCHEMA_VERSION:
544         desc = "Incompatible data schema version";
545         break;
546     case CHIP_ERROR_MISMATCH_UPDATE_REQUIRED_VERSION:
547         desc = "Update Required Version mismatch";
548         break;
549     case CHIP_ERROR_ACCESS_DENIED:
550         desc = "The CHIP message is not granted access";
551         break;
552     case CHIP_ERROR_UNKNOWN_RESOURCE_ID:
553         desc = "Unknown resource ID";
554         break;
555     case CHIP_ERROR_VERSION_MISMATCH:
556         desc = "Version mismatch";
557         break;
558     case CHIP_ERROR_UNSUPPORTED_THREAD_NETWORK_CREATE:
559         desc = "Legacy device doesn't support standalone Thread network creation";
560         break;
561     case CHIP_ERROR_INCONSISTENT_CONDITIONALITY:
562         desc = "The Trait Instance is already being updated with a different conditionality";
563         break;
564     case CHIP_ERROR_LOCAL_DATA_INCONSISTENT:
565         desc = "The local data does not match any known version of the Trait Instance";
566         break;
567     case CHIP_EVENT_ID_FOUND:
568         desc = "Event ID matching criteria was found";
569         break;
570     case CHIP_ERROR_INTERNAL:
571         desc = "Internal error";
572         break;
573     case CHIP_ERROR_OPEN_FAILED:
574         desc = "Open file failed";
575         break;
576     case CHIP_ERROR_READ_FAILED:
577         desc = "Read from file failed";
578         break;
579     case CHIP_ERROR_WRITE_FAILED:
580         desc = "Write to file failed";
581         break;
582     case CHIP_ERROR_DECODE_FAILED:
583         desc = "Decoding failed";
584         break;
585     case CHIP_ERROR_SESSION_KEY_SUSPENDED:
586         desc = "Session key suspended";
587         break;
588     case CHIP_ERROR_UNSUPPORTED_WIRELESS_REGULATORY_DOMAIN:
589         desc = "Unsupported wireless regulatory domain";
590         break;
591     case CHIP_ERROR_UNSUPPORTED_WIRELESS_OPERATING_LOCATION:
592         desc = "Unsupported wireless operating location";
593         break;
594     case CHIP_ERROR_MDNS_COLLISSION:
595         desc = "mDNS collission";
596         break;
597     case CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH:
598         desc = "Malformed Interacton Model Attribute Path";
599         break;
600     case CHIP_ERROR_IM_MALFORMED_EVENT_PATH:
601         desc = "Malformed Interacton Model Event Path";
602         break;
603     case CHIP_ERROR_IM_MALFORMED_COMMAND_PATH:
604         desc = "Malformed Interacton Model Command Path";
605         break;
606     case CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_STATUS_ELEMENT:
607         desc = "Malformed Interacton Model Attribute DataElement";
608         break;
609     case CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT:
610         desc = "Malformed Interacton Model Attribute DataElement";
611         break;
612     case CHIP_ERROR_IM_MALFORMED_EVENT_DATA_ELEMENT:
613         desc = "Malformed Interacton Model Event DataElement";
614         break;
615     case CHIP_ERROR_IM_MALFORMED_STATUS_CODE:
616         desc = "Malformed Interacton Model Status Code";
617         break;
618     case CHIP_ERROR_PEER_NODE_NOT_FOUND:
619         desc = "Unable to find the peer node";
620         break;
621     }
622 #endif // !CHIP_CONFIG_SHORT_ERROR_STR
623
624     FormatError(buf, bufSize, "CHIP", err, desc);
625
626     return true;
627 }
628
629 } // namespace chip