Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var Page = function( page_path, options ){
async.each( resources_array, function( resource, cb ){
resource.get(function(err, resource_response) {
if (err) {
var status = err.status || 500;
var status = err.status == 404 ? 404 : 500;
var error = 'Resource error: ' + err.message;
var is_optional = context.is_preview || resource.options.optional;

Expand Down
20 changes: 16 additions & 4 deletions test/solidus.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,21 @@ describe( 'Solidus', function(){
nock('https://solid.us').get('/error/mandatory?test=3').reply(401, {error: 'Nice try'});
nock('https://solid.us').get('/error/optional?test=3').reply(200, {test: 3});
s_request.get('/with_resource_error?test=3')
.expect(401)
.expect(500)
.end(function(err, res) {
assert(res.text.indexOf('Oh no (401)!') > -1);
assert(res.text.indexOf('Oh no (500)!') > -1);
callback(err);
});
},
function(callback) {
// Bad status is available in context
nock('https://solid.us').get('/error/mandatory?test=3').reply(401, {error: 'Nice try'});
nock('https://solid.us').get('/error/optional?test=3').reply(200, {test: 3});
s_request.get('/with_resource_error.json?test=3')
.expect(500)
.end(function(err, res) {
assert.equal(res.body.error.status, 500);
assert.equal(res.body.error.message.status, 401);
callback(err);
});
},
Expand Down Expand Up @@ -1219,9 +1231,9 @@ describe( 'Solidus', function(){
nock('https://solid.us').get('/error/mandatory?test=3').reply(401, {error: 'Nice try'});
nock('https://solid.us').get('/error/optional?test=3').reply(200, {test: 3});
s_request.get('/with_resource_error?test=3')
.expect(401)
.expect(500)
.end(function(err, res) {
assert.equal(res.text, '401 Unauthorized');
assert.equal(res.text, '500 Internal Server Error');
callback(err);
});
}
Expand Down