|  | // Copyright 2023 Google LLC | 
|  | // Use of this source code is governed by a BSD-style license that can be | 
|  | // found in the LICENSE file. | 
|  |  | 
|  | use thiserror::Error; | 
|  |  | 
|  | use bt_common::packet_encoding::Error as PacketError; | 
|  | use bt_gatt::types::{Error as BTGattError, Handle}; | 
|  |  | 
|  | #[derive(Debug, Error)] | 
|  | pub enum Error { | 
|  | #[error("An unsupported opcode ({0:#x}) used in a Broadcast Audio Scan Control Point operation")] | 
|  | OpCodeNotSupported(u8), | 
|  |  | 
|  | #[error("Invalid source id ({0:#x}) used in a Broadcast Audio Scan Control Point operation")] | 
|  | InvalidSourceId(u8), | 
|  |  | 
|  | #[error("Packet serialization/deserialization error: {0}")] | 
|  | Packet(PacketError), | 
|  |  | 
|  | #[error("Malformed service on peer: {0}")] | 
|  | Service(ServiceError), | 
|  |  | 
|  | #[error("GATT operation error: {0}")] | 
|  | Gatt(BTGattError), | 
|  |  | 
|  | #[error("Failure occurred: {0}")] | 
|  | Generic(String), | 
|  | } | 
|  |  | 
|  | /// This error represents an error we found at the remote service | 
|  | /// which prevents us from proceeding further with the client operation. | 
|  | #[derive(Debug, Error, PartialEq)] | 
|  | pub enum ServiceError { | 
|  | #[error("Missing a required service characteristic")] | 
|  | MissingCharacteristic, | 
|  |  | 
|  | #[error("More than one Broadcast Audio Scan Control Point characteristics")] | 
|  | ExtraScanControlPointCharacteristic, | 
|  |  | 
|  | #[error("Failed to configure notification for Broadcast Recieve State characteristic (handle={0:?})")] | 
|  | NotificationConfig(Handle), | 
|  | } |