From 89109a71b807f697cc82b53d45930924b176b4fd Mon Sep 17 00:00:00 2001 From: David Beale Date: Tue, 5 May 2015 11:16:38 +0100 Subject: [PATCH] Custom Error page --- lib/controllers.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/controllers.js b/lib/controllers.js index 89261747..e68378d9 100644 --- a/lib/controllers.js +++ b/lib/controllers.js @@ -35,7 +35,24 @@ module.exports = function (rootDirectory, logger, indexDocument, errorDocument) if (indexDocument) { - return notFoundResponse(req, res); + if (errorDocument) + { + fileStore.getObject(req.bucket, errorDocument, function (err, object, data) { + if (err) + { + console.error('Custom Error Document not found: ' + errorDocument); + return notFoundResponse(req, res); + } + else + { + return buildResponse(req, res, 404, object, data); + } + }); + } + else + { + return notFoundResponse(req, res); + } } else {