• Stars
    star
    244
  • Rank 160,355 (Top 4 %)
  • Language
    JavaScript
  • Created about 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

libuv errno details exposed

node-errno

Better libuv/Node.js/io.js error handling & reporting. Available in npm as errno.

npm Build Status npm

errno exposed

Ever find yourself needing more details about Node.js errors? Me too, so node-errno contains the errno mappings direct from libuv so you can use them in your code.

By errno:

require('errno').errno[3]
// → {
//     "errno": 3,
//     "code": "EACCES",
//     "description": "permission denied"
//   }

By code:

require('errno').code.ENOTEMPTY
// → {
//     "errno": 53,
//     "code": "ENOTEMPTY",
//     "description": "directory not empty"
//   }

Make your errors more descriptive:

var errno = require('errno')

function errmsg(err) {
  var str = 'Error: '
  // if it's a libuv error then get the description from errno
  if (errno.errno[err.errno])
    str += errno.errno[err.errno].description
  else
    str += err.message

  // if it's a `fs` error then it'll have a 'path' property
  if (err.path)
    str += ' [' + err.path + ']'

  return str
}

var fs = require('fs')

fs.readFile('thisisnotarealfile.txt', function (err, data) {
  if (err)
    console.log(errmsg(err))
})

Use as a command line tool:

~ $ errno 53
{
  "errno": 53,
  "code": "ENOTEMPTY",
  "description": "directory not empty"
}
~ $ errno EROFS
{
  "errno": 56,
  "code": "EROFS",
  "description": "read-only file system"
}
~ $ errno foo
No such errno/code: "foo"

Supply no arguments for the full list. Error codes are processed case-insensitive.

You will need to install with npm install errno -g if you want the errno command to be available without supplying a full path to the node_modules installation.

Custom errors

Use errno.custom.createError() to create custom Error objects to throw around in your Node.js library. Create error hierarchies so instanceof becomes a useful tool in tracking errors. Call-stack is correctly captured at the time you create an instance of the error object, plus a cause property will make available the original error object if you pass one in to the constructor.

var create = require('errno').custom.createError
var MyError = create('MyError') // inherits from Error
var SpecificError = create('SpecificError', MyError) // inherits from MyError
var OtherError = create('OtherError', MyError)

// use them!
if (condition) throw new SpecificError('Eeek! Something bad happened')

if (err) return callback(new OtherError(err))

Also available is a errno.custom.FilesystemError with in-built access to errno properties:

fs.readFile('foo', function (err, data) {
  if (err) return callback(new errno.custom.FilesystemError(err))
  // do something else
})

The resulting error object passed through the callback will have the following properties: code, errno, path and message will contain a descriptive human-readable message.

Contributors

Copyright & Licence

Copyright (c) 2012-2015 Rod Vagg (@rvagg)

Made available under the MIT licence:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

through2

Tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise
JavaScript
1,894
star
2

node-worker-farm

Distribute processing tasks to child processes with an über-simple API and baked-in durability & custom concurrency options.
JavaScript
1,744
star
3

github-webhook-handler

Node.js web handler / middleware for processing GitHub Webhooks
JavaScript
783
star
4

bl

Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!
JavaScript
420
star
5

bole

A tiny JSON logger
JavaScript
265
star
6

nodei.co

nodei.co - Node.js badges, that's all
JavaScript
258
star
7

archived-morkdown

A simple Markdown editor
JavaScript
245
star
8

archived-dnt

Docker Node Tester
Shell
222
star
9

ghauth

Create and load persistent GitHub authentication tokens for command-line apps
JavaScript
184
star
10

archived-node-libssh

A Low-level Node.js binding for libssh
C++
132
star
11

archived-traversty

Headache-free DOM collection management and traversal
JavaScript
131
star
12

github-webhook

A flexible web server for reacting GitHub Webhooks
JavaScript
114
star
13

archived-node-pygmentize-bundled

A simple wrapper around Python's Pygments code formatter, with Pygments bundled
HTML
95
star
14

archived-lmdb

C++
85
star
15

jsonist

JSON over HTTP: A simple wrapper around hyperquest for dealing with JSON web APIs
JavaScript
66
star
16

isstream

Determine if an object is a Node.js Stream
JavaScript
63
star
17

polendina

Non-UI browser testing for JavaScript libraries from the command-line
JavaScript
63
star
18

archived-CAPSLOCKSCRIPT

JAVASCRIPT: T-H-E L-O-U-D P-A-R-T-S
JavaScript
60
star
19

archived-gfm2html

Convert a GitHub style Markdown file to HTML, complete with inline CSS
CSS
49
star
20

archived-node-level-session

A very fast and persistent web server session manager backed by LevelDB
JavaScript
49
star
21

cborg

fast CBOR with a focus on strictness
JavaScript
44
star
22

csv2

A Node Streams2 CSV parser
JavaScript
38
star
23

archived-pangyp

Node.js and io.js native addon build tool a (hopefully temporary) fork of TooTallNate/node-gyp
Python
38
star
24

archived-tsml

ES6 template string tag for multi-line cleaning - squash multi-line strings into a single line
JavaScript
37
star
25

archived-node-level-mapped-index

JavaScript
35
star
26

archived-node-rsz

An image resizer for Node.js
JavaScript
34
star
27

iamap

An Immutable Asynchronous Map
JavaScript
31
star
28

archived-servertest

A simple HTTP server testing tool
JavaScript
30
star
29

node-du

A simple JavaScript implementation of `du -sb`
JavaScript
29
star
30

archived-node-brucedown

A near-perfect GitHub style Markdown to HTML converter
JavaScript
29
star
31

rpi-newer-crosstools

Newer cross-compiler toolchains than are available @ https://github.com/raspberrypi/tools
C++
28
star
32

list-stream

Collect chunks / objects from a readable stream, write obejcts / chunks to a writable stream
JavaScript
27
star
33

archived-prr

JavaScript
26
star
34

archived-npm-explicit-deps

Say goodbye to fickle `~` and `^` semver ranges
JavaScript
26
star
35

ghissues

A node library to interact with the GitHub issues API
JavaScript
25
star
36

archived-string_decoder

Moved to https://github.com/nodejs/string_decoder
23
star
37

archived-node-sz

A Node.js utility for determining the dimensions of an image
JavaScript
23
star
38

js-ipld-hashmap

An associative array Map-type data structure for very large, distributed data sets built on IPLD
JavaScript
23
star
39

delayed

A collection of JavaScript helper functions for your functions, using setTimeout() to delay and defer.
JavaScript
22
star
40

archived-npm-publish-stream

A Node.js ReadableStream that emits data for each module published to npm
JavaScript
21
star
41

ghutils

A collection of utility functions for dealing with the GitHub API
JavaScript
20
star
42

archived-node-require-subvert

Yet another `require()` subversion library for mocking & stubbing
JavaScript
19
star
43

archived-level-ttl-cache

A pass-through cache for arbitrary objects or binary data using LevelDB, expired by a TTL
JavaScript
18
star
44

archived-level-spaces

Namespaced LevelUP instances
JavaScript
18
star
45

archived-node-generic-session

A generic web server session manager for use with any storage back-end
JavaScript
18
star
46

node-boganipsum

Node.js Lorem Ipsum ... Bogan Style!
JavaScript
17
star
47

archived-externr

Provide a plug-in mechanism for your JavaScript objects, exposing their inmost secrets
JavaScript
17
star
48

archived-npm-publish-notify

Desktop notifications on npm publish events
JavaScript
15
star
49

archived-new-contributors

Check a GitHub repository for new contributors
JavaScript
15
star
50

archived-iojs-tools

A collection of utilities I use to help with managing io.js business
HTML
15
star
51

archived-blorg

Flexible static blog generator
JavaScript
15
star
52

archived-node-simple-bufferstream

Turn a Node.js Buffer into a ReadableStream
JavaScript
14
star
53

archived-node-slow-stream

A throttleable stream, for working in the slow-lane
JavaScript
13
star
54

archived-node-crp

An image cropper for Node.js
JavaScript
13
star
55

archived-brtapsauce

Browserify TAP test runner for SauceLabs
JavaScript
12
star
56

archived-node-thmb

An image thumbnailer for Node.js
JavaScript
12
star
57

npm-download-counts

Fetch package download counts for packages from the npm registry
JavaScript
12
star
58

archived-nodei.co-chrome

Chrome extension to display nodei.co npm badges on GitHub README files for Node.js packages
JavaScript
11
star
59

ghrepos

A node library to interact with the GitHub repos API
JavaScript
11
star
60

archived-level-updown

LevelDOWN backed by LevelUP
JavaScript
11
star
61

archived-node-level-multiply

Make your LevelUP get(), put() and del() accept multiples keys & values.
JavaScript
11
star
62

ghteams

Node library to interact with the GitHub teams API
JavaScript
10
star
63

ghusers

A node library to interact with the GitHub users API
JavaScript
10
star
64

js-datastore-zipcar

An implementation of a Datastore (https://github.com/ipfs/interface-datastore) for IPLD blocks that operates on ZIP files
JavaScript
9
star
65

archived-bustermove

JavaScript
9
star
66

node-version-data

Load all Node.js and io.js versions and metadata about them
JavaScript
8
star
67

node-fd

File descriptor manager
JavaScript
8
star
68

archived-sanever

A saner semver parser
JavaScript
7
star
69

js-bitcoin-block

A Bitcoin block interface and decoder for JavaScript
JavaScript
7
star
70

ghpulls

A node library to interact with the GitHub pull requests API
JavaScript
7
star
71

testmark.js

Language-agnostic test fixtures in Markdown
JavaScript
6
star
72

campjs-2013-learn-you-node

CSS
5
star
73

archived-quantities

JavaScript library for physical quantity representation and conversion
JavaScript
5
star
74

jsdoc4readme

Generate an API section for a README.md from inline JSDocs
JavaScript
5
star
75

archived-package-use

Use the nodei.co Node.js package download count API to create CSV data on package use
JavaScript
5
star
76

archived-node-ssbl

Super-simple blog loader. Load markdown formatted blog files from a folder as a handy data structure for rendering
JavaScript
5
star
77

mkfiletree

Make a tree of files and directories by from data defined in an object
JavaScript
5
star
78

readfiletree

Deserialize an file/directory tree into object form
JavaScript
4
star
79

archived-check-python

Check for Python on the current system and return the value
JavaScript
4
star
80

archived-colors-tmpl

Simple templating for applying colors.js to strings
JavaScript
4
star
81

bit-sequence

Turn an arbitrary sequence of bits from a byte array and turn it into an integer
JavaScript
4
star
82

nodei.co-npm-dl-api

API server to manage the npm downloads counts and rankings for nodei.co
JavaScript
3
star
83

archived-node-downer-rangedel

A native LevelDOWN plugin providing a rangeDel() method
JavaScript
3
star
84

blake2-node

Node.js BLAKE2 addon
C
3
star
85

js-ipld-schema-describer

Provide an object that suits the Data Model and get a naive IPLD Schema description of it.
JavaScript
3
star
86

nodei.co-pkginfo-api

API server to manage the npm package info data for nodei.co
JavaScript
3
star
87

bsplit2

A Node.js binary transform stream splitting chunks by newline characters
JavaScript
3
star
88

archived-npm-download-db

A local store containing npm download counts for all packages, able to provide rankings
JavaScript
3
star
89

gitexec

A specialised child process spawn for `git` commands
JavaScript
3
star
90

js-fil-utils

Miscellaneous JavaScript Filecoin proofs utilities
JavaScript
3
star
91

archived-kappa-bridge

A bridge for certificate-authenticated npm connections to Kappa registries
JavaScript
3
star
92

node-ci-containers

Dockerfile
2
star
93

r.va.gg

HTML
2
star
94

lxjs2013

JavaScript Databases II
CSS
2
star
95

archived-simpledb2level

Extract complete (or partial / incremental) SimpleDB data to a local LevelDB
JavaScript
2
star
96

iavector

An Immutable Asynchronous Vector
JavaScript
2
star
97

js-bitcoin-extract

Tools to work with the Bitcoin blockchain (and IPLD)
JavaScript
2
star
98

kasm

A WASM thing in Rust that's probably not what you're looking for
Rust
2
star
99

js-ipld-schema-validator

Build fast and strict JavaScript object form validators using IPLD Schemas
JavaScript
2
star
100

js-ipld-vector

A JavaScript implementation of the IPLD Vetor specification
JavaScript
2
star