Skip to main content

zencan_build/
errors.rs

1//! Error types for crate
2//!
3use snafu::Snafu;
4
5/// Error returned when loading a device config
6#[derive(Debug, Snafu)]
7#[snafu(visibility(pub(crate)))]
8#[allow(missing_docs)]
9pub enum CompileError {
10    /// Provided field name is not a valid rust ident
11    #[snafu(display("InvalidFieldName: {field_name} is not a valid rust ident"))]
12    InvalidFieldName { field_name: String },
13    /// Default value is too long for the container size
14    #[snafu(display("DefaultValueTooLong: {message}"))]
15    DefaultValueTooLong { message: String },
16    /// Default value does not match the object type
17    #[snafu(display("DefaultValueTypeMismatch: {message}"))]
18    DefaultValueTypeMismatch { message: String },
19    /// Missing cargo env vars
20    #[snafu(display("NotRunViaCargo: Missing expected cargo env variables"))]
21    NotRunViaCargo,
22    /// An IO error occurred while writing generated code
23    #[snafu(display("Io: {source}"))]
24    Io { source: std::io::Error },
25    /// An error occurred while loading the device config file
26    #[snafu(display("Error loading device config: {source}"))]
27    DeviceConfig {
28        source: zencan_common::device_config::LoadError,
29    },
30}