hcerr

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package hcerr contains helpers to format and sanitize errors before returning them to clients as grpc status errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Externalize

func Externalize(log hclog.Logger, err error, msg string, args ...interface{}) error

Externalize is intended to be called by top-level grpc handler that's about to return an error to the framework. Details from the err will be logged, but not returned directly to the client, to prevent leaking too much detail. If the err includes a grpc status, that, along with the msg and args, will be returned to the client.

Args follow the same pattern as `hclog`. They are expected to be in order of "label, variable, label, variable", etc. Example: `hcerr.Externalize(log, err, "failed doing thing", "id", thing.id, "organization id", org.id)` All args will be printed as strings to transmit to clients, so rather than adding a big complex struct as an arg, pull out the fields of interest and add them as multiple args. These will be displayed as key/value pairs to the client. If there are an odd number of args, this assumes it's a mistake and adds "EXTRA_VALUE_AT_END" as the label for the final arg.

Types

This section is empty.

Jump to

Keyboard shortcuts

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