1.0.17 • Published 9 years ago

define-exceptions v1.0.17

Weekly downloads
4
License
MIT
Repository
github
Last release
9 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

9 years ago

1.0.16

9 years ago

1.0.15

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago