Skip to main content

miden_mast_package/package/
error.rs

1use alloc::string::String;
2
3use miden_core::serde::DeserializationError;
4
5use super::section::SectionId;
6
7/// Errors raised while stripping package-owned debug information.
8#[derive(Debug, thiserror::Error)]
9pub enum PackageStripError {
10    #[error("failed to decode embedded kernel package while stripping debug info: {source}")]
11    DecodeEmbeddedKernel {
12        #[source]
13        source: DeserializationError,
14    },
15}
16
17/// Errors raised while decoding trusted package-owned debug information.
18#[derive(Debug, thiserror::Error)]
19pub enum PackageDebugInfoError {
20    #[error("package debug sections are present but are not trusted")]
21    /// Package debug sections are present on a package that does not trust them.
22    ///
23    /// Normal untrusted deserialization discards package-owned debug sections before returning a
24    /// package. This error protects callers from manually constructed packages, or future
25    /// deserialization paths, that retain debug sections without marking them trusted.
26    UntrustedSections,
27    #[error("package contains multiple '{id}' debug sections")]
28    DuplicateSection {
29        /// Duplicated section identifier.
30        id: SectionId,
31    },
32    #[error("failed to decode '{id}' debug section: {source}")]
33    DecodeSection {
34        /// Section identifier being decoded.
35        id: SectionId,
36        /// Underlying section deserialization error.
37        #[source]
38        source: DeserializationError,
39    },
40    #[error("'{id}' debug section has trailing bytes")]
41    TrailingBytes {
42        /// Section identifier with unused bytes after decoding.
43        id: SectionId,
44    },
45    #[error("invalid package debug info: {message}")]
46    InvalidReference { message: String },
47}