miden_assembly/library/
error.rs

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