https://github.com/orinak/miscue
Something like Error, with status code
https://github.com/orinak/miscue
Last synced: 4 months ago
JSON representation
Something like Error, with status code
- Host: GitHub
- URL: https://github.com/orinak/miscue
- Owner: orinak
- License: mit
- Created: 2014-06-07T12:23:01.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-07-01T14:24:19.000Z (almost 11 years ago)
- Last Synced: 2025-01-11T00:40:22.914Z (5 months ago)
- Language: JavaScript
- Size: 414 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Miscue [](https://travis-ci.org/decanat/miscue)
Miscue class for Decanat, to provide better interface to HTTP errors and status in general.
```js
var Miscue = require('miscue');
// instantiate
var status = new Miscue(422, { email: 'improper' });
// play
status instanceof Error; // returns true
alert(status); // alerts 'client error (422): {"email":"improper"}'
```## Installation
Install with [component](http://component.io):
$ component install decanat/miscue
## API
#### Set custom name ####
```js
var status = new Miscue(422, { email: 'improper' });
// status.name === 'client error'status.set('validation error');
// status.name === 'validation error'status.set(422);
// status.name === 'client error'
```#### Mark as Error ####
```js
var status = new Miscue(600, 'coffee break');
// status instanceof Error === falsestatus.turnError();
// status instanceof Error === true
```## Testing
To test with PhantomJS, run:
$ make test
## License
The MIT License (MIT)