Skip to content

Commit 14e5adf

Browse files
committed
Merge pull request #303 from Martii/documentPageFixes
Fix proper response codes based off of most probable statusCode
2 parents cf66c2e + 356ab0d commit 14e5adf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

controllers/document.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ exports.view = function (aReq, aRes, aNext) {
3434
// Read file listing
3535
function (aCallback) {
3636
fs.readdir(documentPath, function (aErr, aFiles) {
37-
if (aErr) { aCallback('Error retrieving page list'); return; }
37+
if (aErr) {
38+
aCallback({ statusCode: 500, statusMessage : 'Error retrieving page list' });
39+
return;
40+
}
3841

3942
var file = null;
4043

@@ -56,7 +59,10 @@ exports.view = function (aReq, aRes, aNext) {
5659
// Read md file contents
5760
function (aCallback) {
5861
fs.readFile(documentPath + '/' + document + '.md', 'UTF8', function (aErr, aData) {
59-
if (aErr) { aCallback('Error retrieving page'); return; }
62+
if (aErr) {
63+
aCallback({ statusCode: 404, statusMessage: 'Error retrieving page' });
64+
return;
65+
}
6066

6167
var lines = null;
6268
var matches = null;
@@ -101,7 +107,8 @@ exports.view = function (aReq, aRes, aNext) {
101107
async.parallel(tasks, function (aErr) {
102108
if (aErr) {
103109
return statusCodePage(aReq, aRes, aNext, {
104-
statusMessage: aErr
110+
statusCode: aErr.statusCode,
111+
statusMessage: aErr.statusMessage
105112
})
106113
}
107114

0 commit comments

Comments
 (0)