miden_assembly_syntax/library/
error.rs

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