@leafage/server
Version:
The React Server Side Render Framework
46 lines (43 loc) • 1.48 kB
JavaScript
/**
* @leafage/server v1.3.2
*
* Copyright (c) Leafage.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
import { asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../_virtual/_rollupPluginBabelHelpers.js';
import { handleErrorResponse } from '../common/handleErrorResponse.js';
var errorPreset = function errorPreset(ctx) {
ctx.app.use(/*#__PURE__*/function () {
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(err, req, res, next) {
var _handleErrorResponse, statusCode, message, html;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
_handleErrorResponse = handleErrorResponse(err, req, res), statusCode = _handleErrorResponse.statusCode, message = _handleErrorResponse.message;
_context.n = 1;
return ctx.renderer.render('Error', {
statusCode: statusCode,
message: message
});
case 1:
html = _context.v;
res.status(statusCode);
if (html) {
res.send(html);
}
next();
case 2:
return _context.a(2);
}
}, _callee);
}));
return function (_x, _x2, _x3, _x4) {
return _ref.apply(this, arguments);
};
}());
};
export { errorPreset };