catcheach

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: GPL-2.0, GPL-3.0 Imports: 6 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 catcheach provides a middleware for graceful handling of stderr output based on regex patterns

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatchEachMiddleware

type CatchEachMiddleware struct {
}

Line-Based Error Handler

func NewCatchEachMiddleware

func NewCatchEachMiddleware() CatchEachMiddleware

func (CatchEachMiddleware) Apply

func (catchEachMiddleware CatchEachMiddleware) Apply(
	run *pipeline.Run,
	next func(*pipeline.Run),
	executionContext *middleware.ExecutionContext,
)

func (CatchEachMiddleware) String

func (_ CatchEachMiddleware) String() string

Jump to

Keyboard shortcuts

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