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/sdp/error.h" 16 17 namespace bt { 18 namespace sdp { 19 namespace { 20 ErrorCodeToString(ErrorCode code)21constexpr const char* ErrorCodeToString(ErrorCode code) { 22 switch (code) { 23 case ErrorCode::kUnsupportedVersion: 24 return "unsupported version"; 25 case ErrorCode::kInvalidRecordHandle: 26 return "invalid record handle"; 27 case ErrorCode::kInvalidRequestSyntax: 28 return "invalid request syntax"; 29 case ErrorCode::kInvalidSize: 30 return "invalid size"; 31 case ErrorCode::kInvalidContinuationState: 32 return "invalid continuation state"; 33 case ErrorCode::kInsufficientResources: 34 return "insufficient resources"; 35 default: 36 break; 37 } 38 return "unknown status"; 39 } 40 41 } // namespace 42 } // namespace sdp 43 ToString(sdp::ErrorCode ecode)44std::string ProtocolErrorTraits<sdp::ErrorCode>::ToString( 45 sdp::ErrorCode ecode) { 46 return bt_lib_cpp_string::StringPrintf("%s (SDP %#.2x)", 47 bt::sdp::ErrorCodeToString(ecode), 48 static_cast<unsigned int>(ecode)); 49 } 50 51 } // namespace bt 52