UI for Zipcoin Blue
Tennessee Gibbs 0304752480 added pages to master vor 6 Jahren
..
test added pages to master vor 6 Jahren
.istanbul.yml added pages to master vor 6 Jahren
.npmignore added pages to master vor 6 Jahren
MIGRATION.md added pages to master vor 6 Jahren
README.md added pages to master vor 6 Jahren
docs.mli added pages to master vor 6 Jahren
io.js added pages to master vor 6 Jahren
option.js added pages to master vor 6 Jahren
package.json added pages to master vor 6 Jahren
typed.js added pages to master vor 6 Jahren
validation.js added pages to master vor 6 Jahren
wrapped.js added pages to master vor 6 Jahren

README.md

error

Custom errors

Typed Error

var TypedError = require("error/typed")

var ServerError = TypedError({
    type: 'server.5xx',
    message: '{title} server error, status={statusCode}',
    title: null,
    statusCode: null
});
var ClientError = TypedError({
    type: 'client.4xx',
    message: '{title} client error, status={statusCode}',
    title: null,
    statusCode: null
});

var error = ServerError({
    title:'some title',
    statusCode: 500
});
var error2 = ClientError({
    title: 'some title',
    statusCode: 404
});

Wrapped Errors

var net = require('net');
var WrappedError = require('error/wrapped');

var ServerListenError = WrappedError({
    message: 'server: {origMessage}',
    type: 'server.listen-failed',
    requestedPort: null,
    host: null
});

var server = net.createServer();

server.on('error', function onError(err) {
    if (err.code === 'EADDRINUSE') {
        throw ServerListenError(err, {
            requestedPort: 3000,
            host: null
        });
    } else {
        throw err;
    }
});

server.listen(3000);

Installation

npm install error

Contributors

  • Raynos

MIT Licenced