mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-06-18 16:51:17 +02:00
fix(express): Incorrest uses of 400 error codes (#1553)
Fixes incorrest usage of 400 HTTP responses being returned from the
server, in favor of using 422.
Also, changed a few return codes to 401 where it was more appropriate.
See this article for reasoning behind moving to 422, and why 400 isn't
appropriate for these cases.
For ref:
6be12f8a06
Related:
https://github.com/meanjs/mean/pull/1547
https://github.com/meanjs/mean/pull/1510
This commit is contained in:
@@ -17,7 +17,7 @@ exports.create = function (req, res) {
|
||||
|
||||
article.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(400).send({
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
@@ -51,7 +51,7 @@ exports.update = function (req, res) {
|
||||
|
||||
article.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(400).send({
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
@@ -68,7 +68,7 @@ exports.delete = function (req, res) {
|
||||
|
||||
article.remove(function (err) {
|
||||
if (err) {
|
||||
return res.status(400).send({
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
@@ -83,7 +83,7 @@ exports.delete = function (req, res) {
|
||||
exports.list = function (req, res) {
|
||||
Article.find().sort('-created').populate('user', 'displayName').exec(function (err, articles) {
|
||||
if (err) {
|
||||
return res.status(400).send({
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user