xref: /aosp_15_r20/external/pigweed/pw_bluetooth_sapphire/host/common/host_error.cc (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1 // Copyright 2023 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 #include "pw_bluetooth_sapphire/internal/host/common/host_error.h"
16 
17 namespace bt {
18 
HostErrorToString(HostError error)19 std::string HostErrorToString(HostError error) {
20   switch (error) {
21     case HostError::kNotFound:
22       return "not found";
23     case HostError::kNotReady:
24       return "not ready";
25     case HostError::kTimedOut:
26       return "timed out";
27     case HostError::kInvalidParameters:
28       return "invalid parameters";
29     case HostError::kParametersRejected:
30       return "parameters rejected";
31     case HostError::kAdvertisingDataTooLong:
32       return "advertising data too long";
33     case HostError::kScanResponseTooLong:
34       return "scan response too long";
35     case HostError::kCanceled:
36       return "canceled";
37     case HostError::kInProgress:
38       return "in progress";
39     case HostError::kNotSupported:
40       return "not supported";
41     case HostError::kPacketMalformed:
42       return "packet malformed";
43     case HostError::kLinkDisconnected:
44       return "link disconnected";
45     case HostError::kOutOfMemory:
46       return "out of memory";
47     case HostError::kInsufficientSecurity:
48       return "insufficient security";
49     case HostError::kNotReliable:
50       return "not reliable";
51     case HostError::kFailed:
52       return "failed";
53   }
54   return "(unknown)";
55 }
56 
57 }  // namespace bt
58