archivist_lib/events/
error.rs

1// Copyright 2020 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 crate::events::types::Event;
6use fidl_fuchsia_component as fcomponent;
7use futures::channel::mpsc;
8use moniker::MonikerError;
9use thiserror::Error;
10
11#[derive(Debug, Error)]
12pub enum EventError {
13    #[error(transparent)]
14    Fidl(#[from] fidl::Error),
15
16    #[error("incorrect capability name {received} (expected {expected})")]
17    IncorrectName { received: String, expected: &'static str },
18
19    #[error("received an invalid event type {0:?}")]
20    InvalidEventType(fcomponent::EventType),
21
22    #[error("missing `{0}`")]
23    MissingField(&'static str),
24
25    #[error("received an unknown event result {0:?}")]
26    UnknownResult(fcomponent::EventPayload),
27
28    #[error("expected a result in the fuchsia.sys2 event, but none was found")]
29    ExpectedResult,
30
31    #[error("Component error: {0:?}")]
32    ComponentError(fcomponent::Error),
33
34    #[error(transparent)]
35    SendError(#[from] mpsc::TrySendError<Event>),
36
37    #[error(transparent)]
38    Moniker(#[from] MonikerError),
39}