enforce()?

Simen kjaeraas simen.kjaras at gmail.com
Wed Jun 16 15:28:33 PDT 2010


Lutger <lutger.blijdestijn at gmail.com> wrote:

> Suppose for example (actually this is from real life) there is an  
> important
> operation which, as a service, also sends an e-mail notification as part  
> of that
> operation. It is very bad if the operation fails, but a failed  
> notification is
> not that bad. What to do in case of a bug with the e-mail notification?
>
> 1. crash (gracefully), do not complete the operation.
> 2. log the error for the devs to look into (or crash) *after* the  
> operation is
> complete, let the operation go through without the e-mail notification.
>
> Option 1 is annoying and prevents people from getting work done due to a  
> 'minor'
> bug. Option 2 however probably results in this bug either not getting  
> noticed
> quite early enough or ignored in the face of other issues that always  
> seems to
> have higher priority. Choosing for option 2 can also lead to bugs being
> swallowed silently or mistaken for exceptional conditions, which is more
> dangerous.
>
> I don't mean to split hairs, I bet a lot of software has these kind of  
> cases.

How did you end up with an email system that is so horribly broken that
it spits Errors instead of Exceptions when things are not quite the way
it wants them to be?

If it cannot send the email, it may throw an Exception. If you try and
pass it a handwritten letter, it should throw an Error.

Basically, throwing an Exception means 'Your attention please, reactor 5
has a cooling problem you might want to look at', whereas an Error means
'Explosion imminent, get the fuck off outta here!'.

-- 
Simen


More information about the Digitalmars-d mailing list