Skip to main content

mvt_reader/
error.rs

1//! This module provides error types for the `mvt-reader` crate.
2//!
3//! The [`ParserError`] enum represents all possible errors that can occur during
4//! parsing of a vector tile.
5
6/// An error that can occur during parsing of a vector tile.
7///
8/// # Examples
9///
10/// ```
11/// use mvt_reader::error::ParserError;
12///
13/// fn example() -> Result<(), ParserError> {
14///   Err(ParserError::InvalidTags)
15/// }
16/// ```
17#[derive(Debug, thiserror::Error)]
18#[non_exhaustive]
19pub enum ParserError {
20  /// A protobuf decoding failure.
21  #[error("Decode error: {0}")]
22  Decode(#[from] prost::DecodeError),
23
24  /// The layer has an unsupported vector tile version.
25  #[error("Vector tile version not supported for layer `{layer_name}` (found version: {version})")]
26  UnsupportedVersion {
27    layer_name: String,
28    version: u32,
29  },
30
31  /// The tags section of a feature is malformed.
32  #[error("Tags section contains errors")]
33  InvalidTags,
34
35  /// The geometry section of a feature is malformed.
36  #[error("Geometry section contains errors")]
37  InvalidGeometry,
38
39  /// A coordinate value does not fit in the requested numeric type.
40  #[error("Coordinate value {value} overflows the requested type")]
41  CoordinateOverflow {
42    value: i32,
43  }
44}