it("should call handler methods setRun, setInspector, setRequest and setResponse handler is an instance of HandlerBase", function(){ var ouch = getOuchInstance(); function StdErrHandler(){ StdErrHandler.super_.call(this) } util.inherits(StdErrHandler, Ouch.handlers.BaseHandler); var stdHandlerInstance = new StdErrHandler(); sinon.spy(stdHandlerInstance, "setRun"); sinon.spy(stdHandlerInstance, "setInspector"); sinon.spy(stdHandlerInstance, "setRequest"); sinon.spy(stdHandlerInstance, "setResponse"); ouch.pushHandler(stdHandlerInstance); ouch.handleException(new Error('test'), null, null, function(){ stdHandlerInstance.setRun.calledOnce.should.be.ok; stdHandlerInstance.setInspector.calledOnce.should.be.ok; stdHandlerInstance.setRequest.calledOnce.should.be.ok; stdHandlerInstance.setResponse.calledOnce.should.be.ok; }); });
/** * Helper function to create generic error object with http status code * @param {String} name the error name * @param {Number} statusCode the http status code * @returns {Function} the error constructor * @private */ function createError (name, statusCode) { /** * The error constructor * @param {String} message the error message * @param {String} [cause] the error cause * @constructor */ function ErrorCtor (message, cause) { Error.call(this) Error.captureStackTrace(this) this.message = message || name this.cause = cause this.httpStatus = statusCode } util.inherits(ErrorCtor, Error) ErrorCtor.prototype.name = name return ErrorCtor }
var PassThrough = require('stream').PassThrough inherits(MyReadable, Readable) function MyReadable (opts) { Readable.call(this, opts) inherits(MyWritable, Writable) function MyWritable (opts) { Writable.call(this, opts) inherits(MyPassThrough, PassThrough) function MyPassThrough (opts) { PassThrough.call(this, opts)
util.inherits(StdErrHandler, Ouch.handlers.BaseHandler);
if (isNode) { EE.call(this); if (this.prototype) return Util.inherits(this, EE); return new EE();
util.inherits(SocketStub, EventEmitter); SocketStub.prototype.destroy = function (error) { if (error) {
util.inherits(CustomRefDocKey, ODM.RefDocKey);
VError.apply(this, Array.prototype.slice.call(arguments)); util.inherits(VErrorChildNoName, VError); let err = new VErrorChildNoName('top'); assert.equal(err.toString(), 'VErrorChildNoName: top'); WError.apply(this, Array.prototype.slice.call(arguments)); util.inherits(WErrorChildNoName, WError); err = new WErrorChildNoName('top'); assert.equal(err.toString(), 'WErrorChildNoName: top'); VError.apply(this, Array.prototype.slice.call(arguments)); }; util.inherits(VErrorChildAnon, VError); VErrorChildAnon.prototype.name = 'VErrorChildAnon'; let err = new VErrorChildAnon('top'); WError.apply(this, Array.prototype.slice.call(arguments)); }; util.inherits(WErrorChildAnon, WError); WErrorChildAnon.prototype.name = 'WErrorChildAnon'; err = new WErrorChildAnon('top');
}; util.inherits(AvrgirlArduino, EventEmitter);
util.inherits(SocketStub, EventEmitter); SocketStub.prototype.destroy = function (error) { if (error) {
}; util.inherits(WSRECONNECT, events.EventEmitter); module.exports = WSRECONNECT; })();
it("should execute upto a handler only if handler signal ouch to quit via next callback", function(done){ var ouch = getOuchInstance(); function StdErrHandler(){ StdErrHandler.super_.call(this) } util.inherits(StdErrHandler, Ouch.handlers.BaseHandler); StdErrHandler.prototype.handle = function(next, e){ next("handle resp"); }; var stdHandlerInstance = new StdErrHandler(); sinon.spy(stdHandlerInstance, "handle"); var spyErrHandler = sinon.spy(function(next, e){ next("handle resp", Ouch.handlers.BaseHandler.QUIT); }); var error = new Error('test'); ouch.pushHandler(spyErrHandler).pushHandler(stdHandlerInstance); ouch.handleException(error, null, null, function(responses){ stdHandlerInstance.handle.calledOnce.should.not.be.ok; spyErrHandler.calledOnce.should.be.ok; done(); }); });
util.inherits(MyError, Error); MyError.prototype.name = 'MyError';
util.inherits(SocketStub, EventEmitter); SocketStub.prototype.destroy = function (error) { if (error) {
util.inherits(SocketStub, EventEmitter); SocketStub.prototype.destroy = function (error) { if (error) {