500-pagelet
Advanced tools
Comparing version 1.0.1 to 1.0.2
11
index.js
@@ -23,8 +23,10 @@ 'use strict'; | ||
* @param {Error} error Error data and stack. | ||
* @param {String} name Pagelet name that the Error pagelet replaces. | ||
* @api public | ||
*/ | ||
constructor: function constructor(options, error) { | ||
constructor: function constructor(options, error, name) { | ||
Pagelet.prototype.constructor.call(this, options); | ||
this.error = error instanceof Error ? error : {}; | ||
if (name) this.name = name; | ||
this.data = error instanceof Error ? error : {}; | ||
}, | ||
@@ -40,6 +42,7 @@ | ||
render(null, { | ||
message: this.error.message, | ||
stack: this.env !== 'production' ? this.error.stack : '' | ||
env: this.env, | ||
message: this.data.message, | ||
stack: this.env !== 'production' ? this.data.stack : '' | ||
}); | ||
} | ||
}).on(module); |
{ | ||
"name": "500-pagelet", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Default 500 Pagelet used if anything fails in BigPipe", | ||
@@ -17,3 +17,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"pagelet": "1.0.x", | ||
"pagelet": "1.0.0-alpha", | ||
"diagnostics-pagelet": "1.0.x" | ||
@@ -20,0 +20,0 @@ }, |
@@ -62,3 +62,3 @@ describe('500 Pagelet', function () { | ||
assume(Fivehundred).is.a('function'); | ||
assume(Fivehundred.length).to.equal(2); | ||
assume(Fivehundred.length).to.equal(3); | ||
}); | ||
@@ -69,7 +69,13 @@ | ||
assume(pagelet.error).to.be.instanceof(Error); | ||
assume(pagelet.error).to.have.property('message', 'failed test'); | ||
assume(pagelet.error).to.have.property('stack'); | ||
assume(pagelet.error.stack).to.be.an('string'); | ||
assume(pagelet.data).to.be.instanceof(Error); | ||
assume(pagelet.data).to.have.property('message', 'failed test'); | ||
assume(pagelet.data).to.have.property('stack'); | ||
assume(pagelet.data.stack).to.be.an('string'); | ||
}); | ||
it('can be provided with the name of the Pagelet it replaces', function () { | ||
pagelet = new Fivehundred({ temper: new Temper }, new Error('failed test'), 'search'); | ||
assume(pagelet.name).to.equal('search'); | ||
}); | ||
}); | ||
@@ -86,3 +92,3 @@ | ||
pagelet.error = err; | ||
pagelet.data = err; | ||
pagelet.get(function (error, data) { | ||
@@ -99,6 +105,7 @@ assume(error).to.equal(null); | ||
pagelet.error = err; | ||
pagelet.data = err; | ||
pagelet.env = 'production'; | ||
pagelet.get(function (error, data) { | ||
assume(error).to.equal(null); | ||
assume(data.env).to.equal(pagelet.env); | ||
assume(data.message).to.equal(err.message); | ||
@@ -105,0 +112,0 @@ assume(data.stack).to.not.equal(err.stack); |
Sorry, the diff of this file is not supported yet
11717
8
132
+ Addedfabricator@0.4.4(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedpagelet@1.0.0-alpha(transitive)
+ Addedtemper@0.2.2(transitive)
Updatedpagelet@1.0.0-alpha