-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherror.rs
71 lines (62 loc) · 2.61 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
69
70
71
use crate::launch::ProcfileConversionError;
use crate::procfile::ProcfileParsingError;
use indoc::formatdoc;
#[derive(thiserror::Error, Debug)]
pub enum ProcfileBuildpackError {
#[error("Cannot read Procfile contents: {0}")]
CannotReadProcfileContents(std::io::Error),
#[error("Procfile parsing error: {0}")]
ProcfileParsingError(#[from] ProcfileParsingError),
#[error("Procfile conversion error: {0}")]
ProcfileConversionError(#[from] ProcfileConversionError),
}
pub fn error_handler(buildpack_error: ProcfileBuildpackError) -> i32 {
match buildpack_error {
ProcfileBuildpackError::CannotReadProcfileContents(io_error) => {
libherokubuildpack::log_error(
"Cannot read Procfile contents",
formatdoc! {"
Please ensure the Procfile in the root of your application is a readable UTF-8
encoded file and try again.
Underlying cause was: {io_error}
",
io_error = io_error
},
);
}
ProcfileBuildpackError::ProcfileParsingError(parsing_error) => {
libherokubuildpack::log_error(
"Cannot parse Procfile",
formatdoc! {"
Please ensure the Procfile in the root of your application is a readable UTF-8
encoded Procfile as specified on Heroku DevCenter and try again:
https://devcenter.heroku.com/articles/procfile
Underlying cause was: {parsing_error}
",
parsing_error = parsing_error
},
);
}
ProcfileBuildpackError::ProcfileConversionError(conversion_error) => {
libherokubuildpack::log_error(
"Cannot convert Procfile to CNB launch configuration",
formatdoc! {"
This is an unexpected internal error that occurs when a Procfile entry is not
compatible with the CNB launch configuration. At the time of writing, Procfile
process names are a strict subset of CNB launch process names and this should
never happen.
Please report this issue with the details below.
Details: {conversion_error}
",
conversion_error = conversion_error
},
);
}
}
1
}
impl From<ProcfileBuildpackError> for libcnb::Error<ProcfileBuildpackError> {
fn from(error: ProcfileBuildpackError) -> Self {
Self::BuildpackError(error)
}
}