npm.io
0.0.11 • Published 9 years ago

swerrs

Licence
MIT
Version
0.0.11
Deps
0
Vulns
0
Weekly
0

Build Status

Stop Sw'erring, use swerrs


'use strict';

const SwError = require('swerrs');

const InvalidFileError = SwError.extend({
  name: 'InvalidFileError',
  onPush: function(v) {
    if (v.statusCode === 404) {
      this.fileMissing = true;
    }
  }
});

if (!process.env['XANAX']) {
  let err = new InvalidFileError('OMG!!!');

  // or supply it to the constructor... supports varargs and arrays
  err.push({ msg: `where's my file?!!`, statusCode: 404 });

  process.nextTick(() => {
    console.log(JSON.stringify(err, null, 2));
  });
}

Keywords