miden_assembly_syntax/library/
error.rs

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