-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (40 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
var Pagelet = require('pagelet');
//
// Default 500 error pagelet that will be served if none is provided.
//
Pagelet.extend({
name: '500',
path: '/500',
statusCode: 500,
view: '500.html',
pagelets: {
diagnostics: require('diagnostics-pagelet')
},
/**
* Extend the default constructor to allow second data parameter.
*
* @param {Object} options Optional options.
* @param {Error} error Error data and stack.
* @param {String} name Pagelet name that the Error pagelet replaces.
* @api public
*/
constructor: function constructor(options, error, name) {
Pagelet.prototype.constructor.call(this, options);
if (name) this.name = name;
this.data = error instanceof Error ? error : {};
},
/**
* Return available data depending on environment settings.
*
* @param {Function} render Completion callback.
* @api private
*/
get: function get(render) {
render(null, {
env: this.env,
message: this.data.message,
stack: this.env !== 'production' ? this.data.stack : ''
});
}
}).on(module);