errorstack

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MPL-2.0 Imports: 3 Imported by: 16

Documentation

Overview

Package errorstack exposes a set of error handling utilities for consistency across the Temporal Land ecosystem. Every packages leverage this one for error handling.

This package must not import any other package of this ecosystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivityNotConfigured

func ActivityNotConfigured(activity string) error

ActivityNotConfigured is a shortcut to return NewNonRetryableApplicationError with the appropriate error message when an activity is not properly configured to be used by an integration.

func InputNotValid

func InputNotValid(activity string, validations []Validation) error

InputNotValid is a shortcut to return NewNonRetryableApplicationError with the appropriate error message when a workflow or activity input is not valid.

func IntegrationNotReady

func IntegrationNotReady() error

IntegrationNotReady is a shortcut to return NewNonRetryableApplicationError with the appropriate error message when an integration is not ready to be used.

func NewApplicationError

func NewApplicationError(message string, errType string, cause error) error

NewApplicationError is a wrapper to handle Temporal retryable errors consistently in the ecosystem.

func NewNonRetryableApplicationError

func NewNonRetryableApplicationError(message string, errType string, cause error) error

NewNonRetryableApplicationError is a wrapper to handle Temporal non-retryable errors consistently in the ecosystem.

func WorkflowNotConfigured

func WorkflowNotConfigured(workflow string) error

WorkflowNotConfigured is a shortcut to return NewNonRetryableApplicationError with the appropriate error message when a workflow is not properly configured to be used by an integration.

Types

type Error

type Error struct {

	// Integration is the name of the integration defined by the end-user returning
	// the error.
	//
	// Example: "warehouse"
	Integration string `json:"integration,omitempty"`

	// Specification is the name of the specification (if applicable) returning the
	// error.
	//
	// Example: "sqlike"
	Specification string `json:"specification,omitempty"`

	// Message is the top-level message of the error.
	Message string `json:"message"`

	// Validations represents a list of failed input validations. This is mostly
	// used when a specification or integration's Config encountered bad inputs
	// set by end-users.
	Validations []Validation `json:"validations,omitempty"`

	// Children holds child errors encountered in cascade related to the current
	// error.
	Children []error `json:"children,omitempty"`
}

Error implements the Go native error type. It is designed to handle errors from outside of Temporal workflows and activities.

func New

func New(inte, spec, message string) *Error

New returns a new error for the given integration, specification, and top-level error message.

func (*Error) Error

func (err *Error) Error() string

Error returns the stringified version of the error, including its validation failures and children errors. Since Error is designed for errors outside of Temporal workflows and activities, this string is designed for CLIs and humans.

func (*Error) HasChildren

func (err *Error) HasChildren() bool

HasChildren indicates if an error caused other (a.k.a. children) errors.

func (*Error) HasValidations

func (err *Error) HasValidations() bool

HasValidations indicates if an error encountered validation failures.

func (*Error) WithChildren

func (err *Error) WithChildren(children ...error) error

WithChildren adds a list of child errors encountered related to the current error.

func (*Error) WithValidations

func (err *Error) WithValidations(validations ...Validation) error

WithValidations adds validation failures to an error.

type Validation

type Validation struct {

	// Message is the cause of the validation failure.
	Message string `json:"message"`

	// Path represents the path to the key where the validation failure occurred.
	//
	// Example: []string{"Config", "APIKey"}
	Path []string `json:"path,omitempty"`
}

Validation holds some details about an input validation failure.

Jump to

Keyboard shortcuts

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