oxigdal_gpkg/error.rs
1//! Error types for oxigdal-gpkg
2
3use thiserror::Error;
4
5/// Errors that can occur when parsing GeoPackage / SQLite files.
6#[derive(Debug, Error)]
7pub enum GpkgError {
8 /// The binary data does not conform to the expected format.
9 #[error("Invalid format: {0}")]
10 InvalidFormat(String),
11
12 /// An I/O error occurred while reading.
13 #[error("IO error: {0}")]
14 Io(#[from] std::io::Error),
15
16 /// The GeoPackage geometry blob does not start with the expected magic bytes (0x47 0x50).
17 #[error("Invalid GeoPackage geometry magic bytes")]
18 InvalidGeometryMagic,
19
20 /// A WKB geometry could not be parsed.
21 #[error("WKB parse error: {0}")]
22 WkbParseError(String),
23
24 /// The WKB type code is not recognised.
25 #[error("Unknown WKB geometry type: {0}")]
26 UnknownWkbType(u32),
27
28 /// A parse operation needed more bytes than were available.
29 #[error("Insufficient data: needed {needed} bytes, available {available}")]
30 InsufficientData {
31 /// Number of bytes required by the operation.
32 needed: usize,
33 /// Number of bytes actually present in the buffer.
34 available: usize,
35 },
36}