totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

throw4xx problem description #555

Closed ckpiggy closed 7 years ago

ckpiggy commented 7 years ago

I got 2 problem

  1. When I use controller.throw400(' a test error'), the response is 400: Bad Requesta test error. Should it be 400: Bad Request a test error ? (I am not sure if you need to add a space to append the problem description, since we can add the space when we input the description :-) )

  2. When I use controller.res.throw400('a test error'), I got only 400: Bad Request response. The problem description is missing.

luoage commented 7 years ago

you should use router with #404 in the first arguments

F.route('#404', cb)

luoage commented 7 years ago

And if you want to rewrite throw404 method, you should change the prototype Controller.prototype.throw404

ckpiggy commented 7 years ago

@luoage thx for reply. But I don't want to rewrite throw404 method. What I want to address are

  1. Maybe we could add a space in front of the problem message in response body
  2. The behavior are different between controller.throw400 and controller.res.throw400, controller.res.throw400 wont send problem message with response.
petersirka commented 7 years ago

@ckpiggy there is a bug. I have fixed it + I have published a new beta version $ npm install total.js@beta (stable).

@luoage thank you!

ckpiggy commented 7 years ago

Wow so fast! I was trying to send a PR. Thank you @petersirka !

petersirka commented 7 years ago

Thank you!