fuchsia_inspect/reader/
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::writer::Error as WriterError;
6use diagnostics_hierarchy::Error as HierarchyError;
7use inspect_format::{BlockIndex, Error as FormatError};
8use thiserror::Error;
9
10#[derive(Debug, Error)]
11pub enum ReaderError {
12    #[error("FIDL error")]
13    Fidl(#[source] anyhow::Error),
14
15    #[error("Lazy node callback failed")]
16    LazyCallback(#[source] anyhow::Error),
17
18    #[error("expected header block on index 0")]
19    MissingHeader,
20
21    #[error("Cannot find parent block index {0}")]
22    ParentIndexNotFound(BlockIndex),
23
24    #[error("Malformed tree, no complete node with parent=0")]
25    MalformedTree,
26
27    #[error("VMO format error")]
28    VmoFormat(#[from] FormatError),
29
30    #[error("The VMO is in an invalid format")]
31    InvalidVmo,
32
33    #[error("Tried to read more slots than available at block index {0}")]
34    AttemptedToReadTooManyArraySlots(BlockIndex),
35
36    #[error("unexpected array entry type format: {0:?}")]
37    UnexpectedArrayEntryFormat(u8),
38
39    #[error("Failed to parse name at index {0}")]
40    ParseName(BlockIndex),
41
42    #[error("No blocks at BlockIndex {0}")]
43    GetBlock(BlockIndex),
44
45    #[error("Failed to get consistent snapshot")]
46    InconsistentSnapshot,
47
48    #[error("Header missing or is locked")]
49    MissingHeaderOrLocked,
50
51    #[error("Cannot read from no-op Inspector")]
52    NoOpInspector,
53
54    #[cfg(target_os = "fuchsia")]
55    #[error("Failed to call vmo")]
56    Vmo(#[from] zx::Status),
57
58    #[error("Error creating node hierarchy")]
59    Hierarchy(#[from] HierarchyError),
60
61    #[error("Failed to duplicate vmo handle")]
62    DuplicateVmo,
63
64    #[error("Failed to fetch vmo from Tree content")]
65    FetchVmo,
66
67    #[error("Failed to load tree name {0}")]
68    FailedToLoadTree(String),
69
70    #[error("Timed out reading tree")]
71    TreeTimedOut,
72
73    #[error("Failed to lock inspector state")]
74    FailedToLockState(#[source] WriterError),
75
76    #[error("Offset out of bounds while reading")]
77    OffsetOutOfBounds,
78}