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.
45use crate::events::types::Event;
6use fidl_fuchsia_component as fcomponent;
7use futures::channel::mpsc;
8use moniker::MonikerError;
9use thiserror::Error;
1011#[derive(Debug, Error)]
12pub enum EventError {
13#[error(transparent)]
14Fidl(#[from] fidl::Error),
1516#[error("incorrect capability name {received} (expected {expected})")]
17IncorrectName { received: String, expected: &'static str },
1819#[error("received an invalid event type {0:?}")]
20InvalidEventType(fcomponent::EventType),
2122#[error("missing `{0}`")]
23MissingField(&'static str),
2425#[error("received an unknown event result {0:?}")]
26UnknownResult(fcomponent::EventPayload),
2728#[error("expected a result in the fuchsia.sys2 event, but none was found")]
29ExpectedResult,
3031#[error("Component error: {0:?}")]
32ComponentError(fcomponent::Error),
3334#[error(transparent)]
35SendError(#[from] mpsc::TrySendError<Event>),
3637#[error(transparent)]
38Moniker(#[from] MonikerError),
39}