-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report detailed error messages on task update and delete #618
Conversation
b1eb1e7
to
148f3d7
Compare
I've just fixed some copy-paste in error messages but this is ready to review, I'm not working more on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some minor comments, testing locally it works fine! Thank you
} | ||
$result->setMessage($resultMessage); | ||
$result->setIsSuccessful(false); | ||
$result->setResponseCode(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we've been using 500 everywhere but I wonder if it shouldn't be 400 in this case, what do you think? Here and in the other places where the request fails because the user sent a bad input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you mention, most errors would fall under the "bad request" or "forbidden" umbrellas so it makes sense to review them all...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of trying to be more specific with the http result code when we can.
if ($taskDao->batchPartialUpdate($this->tasks) < count($this->tasks)) { | ||
return -1; | ||
} | ||
$results = $taskDao->batchPartialUpdate($this->tasks); | ||
|
||
//TODO: do something meaningful with the list of discarded tasks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with your changes we can remove this comment? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, we don't match the errors with the discarded tasks, so we don't report the client which tasks were successfully created and which weren't...
I'm not sure if we'll ever want to do that, it would increase the client complexity quite a lot.
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error()); | ||
$affectedRows = pg_affected_rows($res); | ||
$result->setIsSuccessful(true); | ||
$result->setMessage('Project deleted successfully.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant Task deleted successfully
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the string of copy-paste errors never ends :)
if (!$projectVO || !$projectVO->getActivation()) { | ||
$result = new OperationResult(false); | ||
$result->setErrorNumber(30); | ||
$result->setResponseCode(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 403 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than one small nit (which could be addressed later), I think this looks good. Thanks for getting the detailed error messages implemented for tasks - this is a huge improvement.
We build an OperationResult for every situation where a task update is denied, and we also capture SQL exceptions and wrap them in OperationResult objects.
Make "error" font red, add an icon next to it and increase message time on screen.
Web services return the code contained in the first OperationResult. Codes have been reviewed to use 400 (bad request) and 403 (forbidden) instead of 500 when they make more sense, which is most known error cases.
148f3d7
to
a89be33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've submitted a new patch set amending the existing patches to address your comments. In a new patch I've reviewed all the error codes related to task create, update and delete and make web services pass them instead of using always 500.
} | ||
$result->setMessage($resultMessage); | ||
$result->setIsSuccessful(false); | ||
$result->setResponseCode(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you mention, most errors would fall under the "bad request" or "forbidden" umbrellas so it makes sense to review them all...
if ($taskDao->batchPartialUpdate($this->tasks) < count($this->tasks)) { | ||
return -1; | ||
} | ||
$results = $taskDao->batchPartialUpdate($this->tasks); | ||
|
||
//TODO: do something meaningful with the list of discarded tasks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, we don't match the errors with the discarded tasks, so we don't report the client which tasks were successfully created and which weren't...
I'm not sure if we'll ever want to do that, it would increase the client complexity quite a lot.
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error()); | ||
$affectedRows = pg_affected_rows($res); | ||
$result->setIsSuccessful(true); | ||
$result->setMessage('Project deleted successfully.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the string of copy-paste errors never ends :)
if (!$projectVO || !$projectVO->getActivation()) { | ||
$result = new OperationResult(false); | ||
$result->setErrorNumber(30); | ||
$result->setResponseCode(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks for your reviews! I understand it can be merged already. |
I'm increasing the error reporting for task update and delete operations, and also making some changes in the front-end to make error messages more noticeable; I'm afraid that users have become accustomed to ignore them.