nrpkgerrors

package
v3.15.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nrpkgerrors introduces support for https://github.com/pkg/errors.

This package improves the class and stack-trace fields of pkg/error errors when they are recorded with Transaction.NoticeError.

Example
package main

import (
	newrelic "github.com/newrelic/go-agent"
	"github.com/newrelic/go-agent/_integrations/nrpkgerrors"
	"github.com/pkg/errors"
)

type rootError string

func (e rootError) Error() string { return string(e) }

func makeRootError() error {
	return errors.WithStack(rootError("this is the original error"))
}

func main() {
	var txn newrelic.Transaction
	e := errors.Wrap(makeRootError(), "extra information")
	// Wrap the error to record stack-trace and class type information from
	// the error's root cause.  Here, "rootError" will be recored as the
	// class and top stack-trace frame will be inside makeRootError().
	// Without nrpkgerrors.Wrap, "*errors.withStack" would be recorded as
	// the class and the top stack-trace frame would be site of the
	// NoticeError call.
	txn.NoticeError(nrpkgerrors.Wrap(e))
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(e error) error

Wrap wraps a pkg/errors error so that when noticed by newrelic.Transaction.NoticeError it gives an improved stacktrace and class type.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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