Exception handling (programming): Difference between revisions

Content deleted Content added
GreenC bot (talk | contribs)
Reformat 1 archive link. Wayback Medic 2.5 per WP:USURPURL and JUDI batch #18
Restarts separate mechanism from policy: Changed internal link to go directly to the article in question.
Line 209:
 
=== Restarts separate mechanism from policy ===
Condition handling moreover provides a [[separation of mechanism fromand policy]]. Restarts provide various possible mechanisms for recovering from error, but do not select which mechanism is appropriate in a given situation. That is the province of the condition handler, which (since it is located in higher-level code) has access to a broader view.
 
An example: Suppose there is a library function whose purpose is to parse a single [[syslog]] file entry. What should this function do if the entry is malformed? There is no one right answer, because the same library could be deployed in programs for many different purposes. In an interactive log-file browser, the right thing to do might be to return the entry unparsed, so the user can see it—but in an automated log-summarizing program, the right thing to do might be to supply null values for the unreadable fields, but abort with an error, if too many entries have been malformed.