fidl_fuchsia_pkg_rewrite_ext/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use thiserror::Error;
use zx_status as zx;

#[allow(missing_docs)]
#[derive(Error, Debug, PartialEq, Eq)]
pub enum RuleParseError {
    #[error("invalid hostname")]
    InvalidHost,

    #[error("paths must start with '/'")]
    InvalidPath,

    #[error("paths should both be a prefix match or both be a literal match")]
    InconsistentPaths,
}

#[allow(missing_docs)]
#[derive(Error, Debug, PartialEq, Eq)]
pub enum RuleDecodeError {
    #[error("unknown variant")]
    UnknownVariant,

    #[error("parse error: {}", _0)]
    ParseError(RuleParseError),
}

impl From<RuleParseError> for RuleDecodeError {
    fn from(x: RuleParseError) -> Self {
        RuleDecodeError::ParseError(x)
    }
}

#[allow(missing_docs)]
#[derive(Debug, Error)]
pub enum EditTransactionError {
    #[error("internal fidl error")]
    Fidl(#[from] fidl::Error),

    #[error("commit error")]
    CommitError(#[source] zx::Status),

    #[error("add error")]
    AddError(#[source] zx::Status),

    #[error("rule decode error")]
    RuleDecodeError(#[from] RuleDecodeError),
}