Skip to content

Commit

Permalink
Update error printing
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Dec 17, 2024
1 parent c18332a commit 8d0afb7
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::launch::ProcfileConversionError;
use crate::procfile::ProcfileParsingError;
use bullet_stream::Print;
use indoc::formatdoc;
use libherokubuildpack::log::log_error;

#[derive(Debug)]
pub(crate) enum ProcfileBuildpackError {
Expand All @@ -11,37 +11,36 @@ pub(crate) enum ProcfileBuildpackError {
}

pub(crate) fn error_handler(buildpack_error: ProcfileBuildpackError) {
let build_output = Print::new(std::io::stdout()).without_header();
match buildpack_error {
ProcfileBuildpackError::CannotReadProcfileContents(io_error) => {
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}
"},
);
build_output.error(formatdoc! {"
Cannot read Procfile contents
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}
"});
}
// There are currently no ways in which parsing can fail, however we will add some in the future:
// https://github.com/heroku/buildpacks-procfile/issues/73
ProcfileBuildpackError::ProcfileParsingError(parsing_error) => match parsing_error {},
ProcfileBuildpackError::ProcfileConversionError(conversion_error) => match conversion_error
{
ProcfileConversionError::InvalidProcessType(libcnb_error) => {
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: {libcnb_error}
"},
);
build_output.error(formatdoc! {"
Cannot convert Procfile to CNB launch configuration
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: {libcnb_error}
"});
}
},
}
Expand Down

0 comments on commit 8d0afb7

Please sign in to comment.