1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use vm_core::errors::KernelError;

use crate::{ast::QualifiedProcedureName, diagnostics::Diagnostic, LibraryNamespace, LibraryPath};

#[derive(Debug, thiserror::Error, Diagnostic)]
pub enum LibraryError {
    #[error("kernel library must contain at least one exported procedure")]
    #[diagnostic()]
    EmptyKernel,
    #[error("duplicate module '{0}'")]
    #[diagnostic()]
    DuplicateModulePath(LibraryPath),
    #[error("invalid export in kernel library: {procedure_path}")]
    InvalidKernelExport { procedure_path: QualifiedProcedureName },
    #[error(transparent)]
    Kernel(#[from] KernelError),
    #[error("library '{name}' contains {count} modules, but the max is {max}")]
    #[diagnostic()]
    TooManyModulesInLibrary {
        name: LibraryNamespace,
        count: usize,
        max: usize,
    },
}