Skip to main content

bt_bass/server/
error.rs

1// Copyright 2026 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use thiserror::Error;
6
7use crate::types::SourceId;
8use bt_common::packet_encoding::Error as PacketError;
9use bt_gatt::types::Error as BTGattError;
10
11/// Errors encountered when operating a BASS GATT server.
12#[derive(Debug, Error)]
13pub enum Error {
14    #[error("Service is already published")]
15    AlreadyPublished,
16
17    #[error("Service should support at least one Broadcast Receive State characteristic")]
18    MissingReceiveState,
19
20    #[error("Exceeded maximum number of Broadcast Receive State characteristics (255)")]
21    ExceedsMaxReceiveStates,
22
23    #[error("An unsupported opcode ({0:#x}) used in Control Point operation")]
24    OpCodeNotSupported(u8),
25
26    #[error("Invalid source id ({0}) used in Control Point operation")]
27    InvalidSourceId(SourceId),
28
29    #[error("Packet encoding/decoding error: {0}")]
30    Packet(#[from] PacketError),
31
32    #[error("GATT operation error: {0}")]
33    Gatt(#[from] BTGattError),
34}