From 8d0afb7d0141c6bb87b0b1a8cb4fb32ca3292757 Mon Sep 17 00:00:00 2001 From: Schneems Date: Mon, 16 Dec 2024 21:27:13 -0600 Subject: [PATCH] Update error printing --- src/error.rs | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/error.rs b/src/error.rs index fba6c3a..28e1dcf 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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 { @@ -11,17 +11,17 @@ 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 @@ -29,19 +29,18 @@ pub(crate) fn error_handler(buildpack_error: ProcfileBuildpackError) { 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} + "}); } }, }