nodeerrno

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package nodeerrno maps operating-system errors to the error codes, descriptions and errnos Node reports for them. Node takes them from libuv: uv_translate_sys_error converts a Windows system error to a libuv errno (error.errno), uv_err_name names the errno (error.code), and uv_strerror describes it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(errno syscall.Errno) (string, bool)

Code returns the Node error code for errno.

func Describe

func Describe(err error) (code, description string, errno int)

Describe returns the error.code, the uv_strerror text and the error.errno of the error Node's fs module reports for err, the failure of an fs call. An error without an errno is ENOENT when it is fs.ErrNotExist and UNKNOWN otherwise.

func Description

func Description(code string) (string, bool)

Description returns libuv's uv_strerror text for a Node error code.

func Errno

func Errno(code string) (int, bool)

Errno returns the errno Node reports (error.errno) for code: the negated POSIX errno, which libuv passes through, when the platform defines one for the code, and libuv's own value otherwise.

func ErrorCode

func ErrorCode(err error) string

ErrorCode returns the Node error code (error.code) for the syscall.Errno that err wraps, or "" when err wraps none or its errno has no code here.

func FromPathError

func FromPathError(err error) error

FromPathError reports err, a failed Go file operation, as the Node fs call behind it. open keeps its path; read, write and close act on a file descriptor, and Node names no path for them. Any other error is returned unchanged.

func MkdirAll

func MkdirAll(dir string, perm os.FileMode) error

MkdirAll creates dir and any missing parents as Node's fs.mkdirSync(dir, {recursive: true, mode}) does, and reports a failure as Node does: with the requested path, EEXIST when dir exists but is not a directory, and ENOTDIR when a parent is not a directory.

func Name

func Name(errno int) (code, description string)

Name returns libuv's uv_err_name and uv_strerror for a libuv errno on the running platform. libuv names an errno it does not know "Unknown system error <errno>" in both (src/uv-common.c uv__unknown_err_code).

Types

type FSError

type FSError struct {
	Syscall, Path, Code string
	Err                 error
}

FSError is the error Node's fs module reports for a failed call. Its message is Node's: "<CODE>: <description>, <syscall> '<path>'", without the path for a call on a file descriptor. Code, when set, is the code Node reports in place of the one Describe finds for Err. Unwrap returns the Go error.

func (*FSError) Error

func (e *FSError) Error() string

func (*FSError) Unwrap

func (e *FSError) Unwrap() error

Jump to

Keyboard shortcuts

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