Am Fri, 17 Aug 2012 12:48:01 +0400
schrieb Dmitry Olshansky <dmitry.o...@gmail.com>:
> […]
> Something like that. With ifs you query important properties about error 
> that allow you to pick the best recover decision. The whole propose of 
> flags is to unify only _important_ items for the _decision_ process and 
> hide useless variability (it still goes to message).
> 
> A comic-book example:
> Top scientist breaks into Mr. President room and cries:
> "We are doomed! Crystal oculator was miscalculated, all readings are 
> under 0.6543124312,  helerium core just melted!"
> 
> Now does it mean it's time to evacuate promptly or instead give order to 
> isolate the secret lab and "end" this guy's project? Unless Mr.President 
> has a nice and long lookup table of all (pseudo) scientific terms he has 
> no clue.

I experimented with an enum that combines some error codes into a common 
action, like "retry later", "authenticate", "give up", the list goes on. But 
for the networking case (and that's why I was asking for an example of a 
broader application) it is actually nice to have exceptions that read like an 
FAQ: Am I still connected? Is the error temporary?

Now to the president: He might have a technical advisor, that translates the 
scientists explanation. Assume I'd implement an NNTP client. The protocol 
allows for sudden state changes by the server, that would cause unexpected 
errors. (Reconfiguration of a running server.) It also allows for extensions, 
that aside from some formalities can add functionality and error codes.
The president would be a programmer who is only interested in simple way to 
read or post in newsgroups with the library hiding all the minutiae of 
different error codes, detecting supported protocol versions or restoring state 
on a reconnect (like which newsgroup was selected).
The technical advisor may want to make use of an extension for authentication 
or searching the newsgroup, so he needs to get at all the information and also 
create raw requests with custom error handling. I think WebDAV is one such 
extension of HTTP.

-- 
Marco

Reply via email to