Skip to main content

copc_streaming/
error.rs

1use thiserror::Error;
2
3use crate::fields::Fields;
4
5/// Errors that can occur when reading a COPC file.
6#[derive(Debug, Error)]
7pub enum CopcError {
8    /// I/O error from the underlying byte source.
9    #[error("I/O error: {0}")]
10    Io(#[from] std::io::Error),
11
12    /// Error parsing LAS header or VLR data.
13    #[error("LAS error: {0}")]
14    Las(#[from] las::Error),
15
16    /// Error during LAZ decompression.
17    #[error("LAZ error: {0}")]
18    Laz(#[from] laz::LasZipError),
19
20    /// The required COPC info VLR was not found.
21    #[error("COPC info VLR not found")]
22    CopcInfoNotFound,
23
24    /// The required LAZ VLR was not found.
25    #[error("LAZ VLR not found")]
26    LazVlrNotFound,
27
28    /// A hierarchy page was shorter than expected.
29    #[error("hierarchy page at offset {offset} truncated")]
30    TruncatedHierarchyPage {
31        /// File offset where the truncated page starts.
32        offset: u64,
33    },
34
35    /// The requested node is not in the loaded hierarchy.
36    #[error("node not found in hierarchy: {0:?}")]
37    NodeNotFound(crate::types::VoxelKey),
38
39    /// Attempted to materialize `las::Point` values from a chunk that was
40    /// decoded with a partial field mask.
41    ///
42    /// A partially-decoded chunk leaves skipped field bytes as zeros in the
43    /// backing buffer, so producing `Point` values from it would silently
44    /// yield wrong data for those fields. Refetch the chunk with `Fields::ALL`
45    /// or use the column-level accessors on [`Chunk`](crate::Chunk) instead.
46    #[error("cannot materialize points from partially-decoded chunk (fields: {0:?})")]
47    PartialDecode(Fields),
48
49    /// Custom error from a [`ByteSource`](crate::ByteSource) implementation.
50    #[error("byte source error: {0}")]
51    ByteSource(Box<dyn std::error::Error + Send + Sync>),
52}