mcavage/node-restify — Issue #47: createServer "formatError" issues
Author: trentm
Created: 2011-11-10 00:46:51+00:00
State: open

I have a restify server and have NOT specified a formatError callback. With code like the following to respond with an error for one of my server's endpoints:

```
if (!zone) {
var e = restify.newError({
httpCode: HttpCodes.Conflict,
restCode: RestCodes.MissingParameter,
message: "'zone' is a required parameter"
});
res.sendError(e)
return next();
}
```

and the response is:

```
HTTP/1.1 409 Conflict
Connection: close
Date: Thu, 10 Nov 2011 00:46:09 GMT
Server: Joyent
X-Api-Version: 1.0.0
X-Request-Id: dc4aae6f-7877-4fe1-97a1-363946646c56
X-Response-Time: 3
Content-Length: 97
Content-MD5: 6t3n7nTlQh/SN9/cZ5QtLg==
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: OPTIONS, GET, HEAD
Access-Control-Allow-Headers: Accept, Content-Type, Content-Length, Date, X-Api-Version
Access-Control-Expose-Headers: X-Api-Version, X-Request-Id, X-Response-Time

{
"code": {
"httpCode": 409,
"message": "MissingParameter"
},
"message": "'zone' is a required parameter"
}
```

Mark said "well that's fucked up."