Struct libherokubuildpack::HerokuBuildpackErrorHandler[][src]

pub struct HerokuBuildpackErrorHandler<E> { /* fields omitted */ }
Expand description

A shared libcnb ErrorHandler for Heroku buildpacks

It outputs generic libcnb errors in a consistent style using the logging functions from this create. Buildpack specific errors are handled by a custom handler.

Implementations

Constructs a new HerokuBuildpackErrorHandler with the given error handler for custom buildpack errors.

Example:

use libherokubuildpack::{HerokuBuildpackErrorHandler, log_error};

enum FooBuildpackError {
    CannotExecuteFooBuildTool(std::io::Error),
    InvalidFooDescriptorToml
}

fn handle_foo_buildpack_error(e: FooBuildpackError) -> i32 {
    match e {
        FooBuildpackError::InvalidFooDescriptorToml => {
            log_error("Invalid foo.toml", "Your app's foo.toml is invalid!");
            23
        },
        FooBuildpackError::CannotExecuteFooBuildTool(inner) => {
            log_error("Cannot execute foo buildtool", format!("Cause: {}", &inner));
            42
        }
    }
}

let libcnb_error_handler
    = HerokuBuildpackErrorHandler::new(Box::new(handle_foo_buildpack_error));

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.