fidl_fuchsia_pkg_rewrite_ext/
errors.rs

1// Copyright 2019 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;
6use zx_status as zx;
7
8#[allow(missing_docs)]
9#[derive(Error, Debug, PartialEq, Eq)]
10pub enum RuleParseError {
11    #[error("invalid hostname")]
12    InvalidHost,
13
14    #[error("paths must start with '/'")]
15    InvalidPath,
16
17    #[error("paths should both be a prefix match or both be a literal match")]
18    InconsistentPaths,
19}
20
21#[allow(missing_docs)]
22#[derive(Error, Debug, PartialEq, Eq)]
23pub enum RuleDecodeError {
24    #[error("unknown variant")]
25    UnknownVariant,
26
27    #[error("parse error: {}", _0)]
28    ParseError(RuleParseError),
29}
30
31impl From<RuleParseError> for RuleDecodeError {
32    fn from(x: RuleParseError) -> Self {
33        RuleDecodeError::ParseError(x)
34    }
35}
36
37#[allow(missing_docs)]
38#[derive(Debug, Error)]
39pub enum EditTransactionError {
40    #[error("internal fidl error")]
41    Fidl(#[from] fidl::Error),
42
43    #[error("commit error")]
44    CommitError(#[source] zx::Status),
45
46    #[error("add error")]
47    AddError(#[source] zx::Status),
48
49    #[error("rule decode error")]
50    RuleDecodeError(#[from] RuleDecodeError),
51}