catch

package
v0.32.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2021 License: GPL-2.0, GPL-3.0 Imports: 5 Imported by: 0

README

catch - Error Handling Middleware

Arguments

Matching rules

Define error matching rules using the pattern argument. It expects a regex that matches each handled line in the StdErr output.

Any errors that occur will be matched against your rules, and the first match will be applied. Subsequent pipes will not see these errors.

- some_pipeline:
    catch:
      pattern: "^Error: ",
Handling rules

The ignore argument will cause all matched errors to be swallowed instead of being passed to subsequent pipelines. Use with caution.

- some_pipeline:
    catch:
      pattern: "^Error: ",
      ignore: true

Some errors are best treated as output. The divert-to-output argument prints the error message in StdOut and does not pass it on.

- some_pipeline:
    catch:
      pattern: "^Error: ",
      divert-to-output: true

Use the explain-error argument to wrap the error using a GoLang format string. The placeholder %w can be used to refer to the underlying error. Note that a handler will not swallow the error, unless combined with another argument, such as ignore.

- some_pipeline:
    catch:
      pattern: "^Error: ",
      explain-error: "failed to parse configuration file due to syntax error: %w"

Documentation

Overview

Package catch provides a middleware for graceful handling of stderr output

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware added in v0.32.2

type Middleware struct {
}

Middleware implements a handler for stderr output

func NewMiddleware added in v0.32.2

func NewMiddleware() Middleware

NewMiddleware creates a new Middleware instance

func (Middleware) Apply added in v0.32.2

func (catchMiddleware Middleware) Apply(
	run *pipeline.Run,
	next func(*pipeline.Run),
	executionContext *middleware.ExecutionContext,
)

Apply is where the middleware's logic resides

It adapts the run based on its slice of the run's arguments. It may also trigger side effects such as executing shell commands or full runs of other pipelines. When done, this function should call next in order to continue unwinding the stack.

func (Middleware) String added in v0.32.2

func (Middleware) String() string

String is a human-readable description

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL