Debian Codegraph @

contrib/bindings/go/internal/libpathrs/error_unix.go

raw symbols SCIP
1 //go:build linux
2
3 // TODO: Use "go:build unix" once we bump the minimum Go version 1.19.
4
5 // SPDX-License-Identifier: MPL-2.0
6 /*
7 * libpathrs: safe path resolution on Linux
8 * Copyright (C) 2019-2025 SUSE LLC
9 * Copyright (C) 2026 Aleksa Sarai <[email protected]>
10 *
11 * This Source Code Form is subject to the terms of the Mozilla Public
12 * License, v. 2.0. If a copy of the MPL was not distributed with this
13 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
14 */
15
16 package libpathrs
17
18 import (
19 "syscall"
20 )
21
22 // Error represents an underlying libpathrs error.
23 type Error struct {
24 description string
25 errno syscall.Errno
26 }
27
28 // Error returns a textual description of the error.
29 func (err *Error) Error() string {
30 return err.description
31 }
32
33 // Unwrap returns the underlying error which was wrapped by this error (if
34 // applicable).
35 func (err *Error) Unwrap() error {
36 if err.errno != 0 {
37 return err.errno
38 }
39 return nil
40 }