1.0.17 • Published 10 years ago

define-exceptions v1.0.17

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

define-exceptions

Single exception

var de = require('define-exceptions');
var SuperException = de.Exception(Error, 'SuperException', 'Super new exception with %foo% and %bar%');

console.log(SuperException instanceof Error); // true

throw new SuperException({foo: 'test1', bar: 'test2'});
//SuperException: Super new exception with test1 and test2

Multiple exceptions

//exceptions.js
var de = require('define-exceptions');

var DiException = de.Exception(Error, 'DiException', 'Unknown MicroDi exception');

var Exceptions = de.Exceptions(DiException, {
    ProtoNotFound: 'Prototype not found in path %path%, params: %params%',
});

Exceptions.DiException = DiException;

module.exports = Exceptions;

Assertions

var Exceptions = require('./exceptions');



throw new Exceptions.ProtoNotFound({path: '/path/to', params: [1, 2, 3]});

Exceptions.ProtoNotFound.ok(false, {path: '/path/to', params: [1, 2, 3]});
1.0.17

10 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

11 years ago

1.0.5

11 years ago

1.0.4

11 years ago

1.0.3

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago