blob: 209a59ca308b36458a4139f64c6cea1f8c99ca86 [file] [log] [blame]
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package derrors defines internal error values to categorize the different
// types error semantics supported by the vulndb.
package derrors
import "fmt"
// Wrap adds context to the error and allows
// unwrapping the result to recover the original error.
// Example:
// defer derrors.Wrap(&err, "copy(%s, %s)", dst, src)
func Wrap(errp *error, format string, args ...interface{}) {
if *errp != nil {
*errp = fmt.Errorf("%s: %w", fmt.Sprintf(format, args...), *errp)