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::writer::Error as WriterError;
6use diagnostics_hierarchy::Error as HierarchyError;
7use inspect_format::{BlockIndex, Error as FormatError};
8use thiserror::Error;
910#[derive(Debug, Error)]
11pub enum ReaderError {
12#[error("FIDL error")]
13Fidl(#[source] anyhow::Error),
1415#[error("Lazy node callback failed")]
16LazyCallback(#[source] anyhow::Error),
1718#[error("expected header block on index 0")]
19MissingHeader,
2021#[error("Cannot find parent block index {0}")]
22ParentIndexNotFound(BlockIndex),
2324#[error("Malformed tree, no complete node with parent=0")]
25MalformedTree,
2627#[error("VMO format error")]
28VmoFormat(#[from] FormatError),
2930#[error("The VMO is in an invalid format")]
31InvalidVmo,
3233#[error("Tried to read more slots than available at block index {0}")]
34AttemptedToReadTooManyArraySlots(BlockIndex),
3536#[error("unexpected array entry type format: {0:?}")]
37UnexpectedArrayEntryFormat(u8),
3839#[error("Failed to parse name at index {0}")]
40ParseName(BlockIndex),
4142#[error("No blocks at BlockIndex {0}")]
43GetBlock(BlockIndex),
4445#[error("Failed to get consistent snapshot")]
46InconsistentSnapshot,
4748#[error("Header missing or is locked")]
49MissingHeaderOrLocked,
5051#[error("Cannot read from no-op Inspector")]
52NoOpInspector,
5354#[cfg(target_os = "fuchsia")]
55 #[error("Failed to call vmo")]
56Vmo(#[from] zx::Status),
5758#[error("Error creating node hierarchy")]
59Hierarchy(#[from] HierarchyError),
6061#[error("Failed to duplicate vmo handle")]
62DuplicateVmo,
6364#[error("Failed to fetch vmo from Tree content")]
65FetchVmo,
6667#[error("Failed to load tree name {0}")]
68FailedToLoadTree(String),
6970#[error("Timed out reading tree")]
71TreeTimedOut,
7273#[error("Failed to lock inspector state")]
74FailedToLockState(#[source] WriterError),
7576#[error("Offset out of bounds while reading")]
77OffsetOutOfBounds,
78}