Skip to main content

chaste_types/
error.rs

1// SPDX-FileCopyrightText: 2024 The Chaste Authors
2// SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
3
4pub use nodejs_semver::{SemverError, SemverErrorKind};
5use thiserror::Error;
6
7use crate::package::PackageID;
8
9#[derive(Debug, Error, PartialEq)]
10#[non_exhaustive]
11pub enum Error {
12    #[error("Root package id was not set when building a Chastefile")]
13    MissingRootPackageID,
14
15    #[error("Duplicate package added: {0:?}")]
16    DuplicatePackage(PackageID),
17
18    #[error("Invalid package name: {0:?}")]
19    InvalidPackageName(String),
20
21    #[error("Invalid source/version specifier: {0:?}")]
22    InvalidSVS(String),
23
24    #[error("Invalid module path: {0:?}")]
25    InvalidModulePath(String),
26
27    #[error("Semver error: {0:?}")]
28    SemverError(#[from] SemverError),
29}
30
31pub type Result<T, E = Error> = std::result::Result<T, E>;