-
Notifications
You must be signed in to change notification settings - Fork 6
/
error.rs
68 lines (50 loc) · 2.09 KB
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crate::data::launch::ProcessTypeError;
use crate::layer::HandleLayerError;
use libcnb_common::toml_file::TomlFileError;
use std::fmt::Debug;
/// A specialized Result type for libcnb.
///
/// This type is broadly used across libcnb for any operation which may produce an error.
pub type Result<T, E> = std::result::Result<T, Error<E>>;
/// An error that occurred during buildpack execution.
#[derive(thiserror::Error, Debug)]
pub enum Error<E> {
#[error("HandleLayer error: {0}")]
HandleLayerError(#[from] HandleLayerError),
#[error("Process type error: {0}")]
ProcessTypeError(#[from] ProcessTypeError),
#[error("Couldn't determine app directory: {0}")]
CannotDetermineAppDirectory(std::io::Error),
#[error("Couldn't determine buildpack directory: {0}")]
CannotDetermineBuildpackDirectory(std::env::VarError),
#[error("Couldn't determine target os: {0}")]
CannotDetermineTargetOs(std::env::VarError),
#[error("Couldn't determine target arch: {0}")]
CannotDetermineTargetArch(std::env::VarError),
#[error("Couldn't create platform from platform path: {0}")]
CannotCreatePlatformFromPath(std::io::Error),
#[error("Couldn't read buildpack plan: {0}")]
CannotReadBuildpackPlan(TomlFileError),
#[error("Couldn't read buildpack.toml: {0}")]
CannotReadBuildpackDescriptor(TomlFileError),
#[error("Couldn't read store.toml: {0}")]
CannotReadStore(TomlFileError),
#[error("Couldn't write build plan: {0}")]
CannotWriteBuildPlan(TomlFileError),
#[error("Couldn't write launch.toml: {0}")]
CannotWriteLaunch(TomlFileError),
#[error("Couldn't write store.toml: {0}")]
CannotWriteStore(TomlFileError),
#[error("Couldn't write build SBOM files: {0}")]
CannotWriteBuildSbom(std::io::Error),
#[error("Couldn't write launch SBOM files: {0}")]
CannotWriteLaunchSbom(std::io::Error),
#[error("Buildpack error: {0:?}")]
BuildpackError(E),
}
#[cfg(feature = "anyhow")]
impl From<anyhow::Error> for Error<anyhow::Error> {
fn from(error: anyhow::Error) -> Self {
Self::BuildpackError(error)
}
}