Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

Commit

Permalink
Improved test coverage and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
akyoto committed Sep 21, 2016
1 parent b3b4d67 commit 35dc1e2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
11 changes: 4 additions & 7 deletions lib/Server/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ let handleError = (error, request, response) => {
console.error(chalk.bold(request.method, request.url))
response.writeHead(500)

if(error.stack) {
console.error(chalk.red(error.stack))
response.end(error.stack)
} else {
console.error(chalk.red(error))
response.end(error)
}
let message = error.stack || error

console.error(chalk.red(message))
response.end(message)
}

module.exports = function(route, request, response) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aero",
"version": "1.6.16",
"version": "1.6.17",
"description": "The fastest web framework on the node platform.",
"repository": "aerojs/aero",
"homepage": "https://github.com/aerojs/aero",
Expand Down
1 change: 1 addition & 0 deletions test/apps/demo/pages/error/controller/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.get = (request, response) => response.render(doesNotExist)
10 changes: 7 additions & 3 deletions test/tests/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ test('Test App: Demo', function*(t) {
t.equal((yield fetch(app, '/redirect')).body, (yield fetch(app, '/')).body, '/redirect')
t.equal((yield fetch(app, '/sendfile')).body, require('fs').readFileSync('package.json', 'utf8'), '/sendfile')

let syntaxError = yield fetch(app, '/syntaxerror')
t.ok(syntaxError.body.startsWith('SyntaxError'), '/syntaxerror')
t.equal(syntaxError.statusCode, 500, '/syntaxerror (status code)')
let syntaxError = yield fetch(app, '/error/syntax')
t.ok(syntaxError.body.startsWith('SyntaxError'), '/error/syntax')
t.equal(syntaxError.statusCode, 500, '/error/syntax (status code)')

let controllerError = yield fetch(app, '/error/controller')
t.ok(controllerError.body.startsWith('ReferenceError'), '/error/controller')
t.equal(controllerError.statusCode, 500, '/error/controller (status code)')

// Live modification
let testPath = 'test/apps/demo/pages/home/home.jade'
Expand Down

0 comments on commit 35dc1e2

Please sign in to comment.