blob: 8ada1714d35382ed096651e2f04a1e05e1e98d0d [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "error.h"
namespace bt {
namespace {
std::string ErrorToString(att::ErrorCode ecode) {
switch (ecode) {
case att::ErrorCode::kInvalidHandle:
return "invalid handle";
case att::ErrorCode::kReadNotPermitted:
return "read not permitted";
case att::ErrorCode::kWriteNotPermitted:
return "write not permitted";
case att::ErrorCode::kInvalidPDU:
return "invalid PDU";
case att::ErrorCode::kInsufficientAuthentication:
return "insuff. authentication";
case att::ErrorCode::kRequestNotSupported:
return "request not supported";
case att::ErrorCode::kInvalidOffset:
return "invalid offset";
case att::ErrorCode::kInsufficientAuthorization:
return "insuff. authorization";
case att::ErrorCode::kPrepareQueueFull:
return "prepare queue full";
case att::ErrorCode::kAttributeNotFound:
return "attribute not found";
case att::ErrorCode::kAttributeNotLong:
return "attribute not long";
case att::ErrorCode::kInsufficientEncryptionKeySize:
return "insuff. encryption key size";
case att::ErrorCode::kInvalidAttributeValueLength:
return "invalid attribute value length";
case att::ErrorCode::kUnlikelyError:
return "unlikely error";
case att::ErrorCode::kInsufficientEncryption:
return "insuff. encryption";
case att::ErrorCode::kUnsupportedGroupType:
return "unsupported group type";
case att::ErrorCode::kInsufficientResources:
return "insuff. resources";
default:
break;
}
return "(unknown)";
}
} // namespace
std::string ProtocolErrorTraits<att::ErrorCode>::ToString(att::ErrorCode ecode) {
return bt_lib_cpp_string::StringPrintf("%s (ATT %#.2hhx)", ErrorToString(ecode).c_str(), ecode);
}
} // namespace bt