Debian Codegraph @

pathrs-lite/internal/gocompat/gocompat_errors_go120.go

raw
1 // SPDX-License-Identifier: BSD-3-Clause
2 //go:build linux && go1.20
3
4 // Copyright (C) 2024 SUSE LLC. All rights reserved.
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file.
7
8 package gocompat
9
10 import (
11 "fmt"
12 )
13
14 // WrapBaseError is a helper that is equivalent to fmt.Errorf("%w: %w"), except
15 // that on pre-1.20 Go versions only errors.Is() works properly (errors.Unwrap)
16 // is only guaranteed to give you baseErr.
17 func WrapBaseError(baseErr, extraErr error) error {
18 return fmt.Errorf("%w: %w", extraErr, baseErr)
19 }