Simon (
swaldman) wrote in
dw_dev_training2013-07-11 05:21 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[site community profile]](https://www.dreamwidth.org/img/comm_staff.png)
Entry tags:
Error handling - help please?
Does anybody have time to do a quick rundown on how error handling should be done in DW, going forward?
There are a number of different ways of doing things within the codebase at present. I've tended to adopt LJ::throw for new stuff because it seemed comprehensible(!), but Mark has recently said in a review "I... don't think we use LJ::Error anywhere useful anymore. It's pretty old.". (given where the comment was made I assume that it referred to a LJ::throw statement, which I imagine must be part of a LJ::Error package)
So I'm wondering what best practice is now, and thus what we should do in new code?
Thanks
There are a number of different ways of doing things within the codebase at present. I've tended to adopt LJ::throw for new stuff because it seemed comprehensible(!), but Mark has recently said in a review "I... don't think we use LJ::Error anywhere useful anymore. It's pretty old.". (given where the comment was made I assume that it referred to a LJ::throw statement, which I imagine must be part of a LJ::Error package)
So I'm wondering what best practice is now, and thus what we should do in new code?
Thanks
no subject
Not really -- workers usually have their own sort of
$job->failed("message")
kind of semantics. In those cases, the error message also usually gets shown to the user (in permanent failures anyway), but even temporary failures show up in the error logs which are read by non-developers.In workers, you should think about what kind of error it is -- temporary or permanent -- and make sure you always exit out through one of those methods, with an error message that is, hopefully, useful for the user.