properly encode string errors when accept is application/json

This commit is contained in:
Nikolai Onken 2015-05-06 15:18:58 +02:00
parent 9cc8b588c2
commit 685cf701e0
2 changed files with 5 additions and 1 deletions

View File

@ -11,7 +11,6 @@
},
"dependencies": {
"acorn": ">=0.11.0",
"amd-loader": "",
"async": "^0.9.0",
"base64id": "~0.1.0",
"c9": "",

View File

@ -1,5 +1,7 @@
"use strict";
var error = require("http-error");
plugin.consumes = [
"connect",
"connect.static",
@ -78,6 +80,9 @@ function plugin(options, imports, register) {
connect.useStart(frontdoor.middleware.jsonWriter());
connect.useError(function(err, req, res, next) {
if (typeof err == "string")
err = new error.InternalServerError(err);
var statusCode = parseInt(err.code || err.status || res.statusCode, 10) || 500;
if (statusCode < 400)