Feedback Both techniques accomplish a report, but immediate reporting is more robust 

Forum: Com Sci 12500, U Chicago, Autumn 2002, Discuss Classwork
Re: News Project Step #1, due Friday 8 November
Re: Question Reporting errors in procedure (Nathan Krapf)
Date: 2002, Nov 07
From: Mike O'Donnell <odonnell@cs.uchicago.edu>

When reporting errors, should we get the error to be reported in the procedure that is being called, or if we know a subsequent procedure call will pick it up, can we wait until then?
Technically, the execution of a procedure includes all of the recursive executions of that procedure and others that happen as a result. So, when a procedure has a responsibility to report an error, it may satisfy that responsibility by calling another procedure to do so. In effect, that always happens when you call error to do the error reporting.

But there are two reasons to prefer putting each procedure's error reporting code directly in its body rather than depending on another procedure in the abstraction that it calls:

  1. The code itself is more robust. A change to one procedure won't accidentally break the error reporting in another one. you don't risk delaying the error report forever in an infinite recursion. Earliest possible reporting of errors is normally a win.

  2. The error reports can be more informative. It's usually more helpful to know which procedure initially received improper arguments.



Mike O'D.


to: "Both techniques accomplish a report, but immediate reporting is more robust"