miden_assembly_syntax/library/
error.rs

1use miden_core::errors::KernelError;
2
3use crate::{
4    ast::QualifiedProcedureName,
5    diagnostics::{Diagnostic, miette},
6};
7
8#[derive(Debug, thiserror::Error, Diagnostic)]
9pub enum LibraryError {
10    #[error("library must contain at least one exported procedure")]
11    #[diagnostic()]
12    NoExport,
13    #[error("invalid export in kernel library: {procedure_path}")]
14    InvalidKernelExport { procedure_path: QualifiedProcedureName },
15    // Technically KernelError is the source error here, but since LibraryError is sometimes
16    // converted into a Report and that doesn't implement core::error::Error, treating
17    // KernelError as a source error would effectively swallow it, so we include it in the
18    // error message instead.
19    #[error("failed to convert library into kernel library: {0}")]
20    KernelConversion(KernelError),
21    #[error("invalid export: no procedure root for {procedure_path} procedure")]
22    NoProcedureRootForExport { procedure_path: QualifiedProcedureName },
23}