catch

package
v0.30.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: 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

The `catch` middleware enables graceful handling of stderr output

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatchMiddleware

type CatchMiddleware struct {
}

Error Handler

func NewCatchMiddleware

func NewCatchMiddleware() CatchMiddleware

func (CatchMiddleware) Apply

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

func (CatchMiddleware) String

func (_ CatchMiddleware) String() string

Jump to

Keyboard shortcuts

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