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::Ref;
6use fidl_fuchsia_component_test as ftest;
7use thiserror::Error;
89#[derive(Debug, Error)]
10pub enum Error {
11#[error("route is missing source")]
12MissingSource,
1314#[error("the realm builder server returned an error: {0:?}")]
15ServerError(ftest::RealmBuilderError),
1617#[error("an internal error was encountered while working with the realm builder server")]
18FidlError(#[from] fidl::Error),
1920#[error("failed to open \"/pkg\": {0:?}")]
21FailedToOpenPkgDir(fuchsia_fs::node::OpenError),
2223#[error("failed to connect to realm builder server: {0:?}")]
24ConnectToServer(anyhow::Error),
2526#[error("unable to destroy realm, the destroy waiter for root has already been taken")]
27DestroyWaiterTaken,
2829#[error("failed to bind to realm: {0:?}")]
30FailedToBind(anyhow::Error),
3132#[error("failed to create child: {0:?}")]
33FailedToCreateChild(anyhow::Error),
3435#[error("failed to destroy child: {0:?}")]
36FailedToDestroyChild(anyhow::Error),
3738#[error("unable to use reference {0} in realm {1:?}")]
39RefUsedInWrongRealm(Ref, String),
4041#[error("could not start root component using lifecycle controller: {0:?}")]
42CannotStartRootComponent(anyhow::Error),
4344#[error("from_dictionary is not supported for capability type: {0:?}")]
45FromDictionaryNotSupported(ftest::Capability),
46}
4748impl From<ftest::RealmBuilderError> for Error {
49fn from(err: ftest::RealmBuilderError) -> Self {
50Self::ServerError(err)
51 }
52}
5354// TODO: Define an error type for ScopedInstance