fidl_next_protocol/error.rs
1// Copyright 2024 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 fidl_next_codec::DecodeError;
8
9/// Errors that can be produced by FIDL clients and servers.
10#[derive(Error, Debug)]
11pub enum ProtocolError<E> {
12 /// The underlying transport encountered an error.
13 #[error("the underlying transport encountered an error: {0}")]
14 TransportError(E),
15
16 /// The client or server received a message with an invalid protocol header.
17 #[error("received a message with an invalid message header: {0}")]
18 InvalidMessageHeader(DecodeError),
19
20 /// The client or server received a response for a two-way message which did not occur.
21 #[error("received a response which did not correspond to a pending request: {0}")]
22 UnrequestedResponse(u32),
23
24 /// The client or server received a response with the wrong ordinal for the two-way message.
25 #[error(
26 "received a response with the wrong ordinal for the two-way message; expected ordinal \
27 {expected}, but got ordinal {actual}"
28 )]
29 InvalidResponseOrdinal {
30 /// The expected ordinal of the response
31 expected: u64,
32 /// The actual ordinal of the response
33 actual: u64,
34 },
35}