1 | exports.types = {}
|
2 | exports.types.Redirect = class Redirect
|
3 | constructor: (@location, @code=302, @message) ->
|
4 | @message ?= "Redirecting to #{@location}"
|
5 |
|
6 | exports.handlers =
|
7 | Redirect: (err, req, res, next) ->
|
8 | res.setHeader 'Location', err.location
|
9 | res.statusCode = err.code
|
10 | res.end err.message
|
11 |
|
12 | exports.types.NoResponseData = ->
|
13 | @message = "Response data is undefined"
|
14 | @code = 500
|
15 | Error.captureStackTrace @, exports.types.NoResponseData
|
16 |
|
17 | exports.types.InvalidParameter = (type, thing) ->
|
18 | @message = "Bad Request: invalid #{type} #{thing}"
|
19 | @code = 422
|
20 | Error.captureStackTrace @, exports.types.InvalidParameter
|
21 |
|
22 | exports.types.NotFound = (type, value) ->
|
23 | @code = 404
|
24 | if type? and value?
|
25 | @message = "#{type} '#{value}' not found"
|
26 | else if type?
|
27 | @message = "#{type} not found"
|
28 | else
|
29 | @message = "Not found"
|
30 | Error.captureStackTrace @, exports.types.NotFound
|