[Prev][Next][Index][Thread]
A tale of restarts
-
To: info-dylan@ai.mit.edu
-
Subject: A tale of restarts
-
From: chris@double.co.nz (Chris Double)
-
Date: Sun, 23 Apr 2000 09:15:02 -0400 (EDT)
-
Organization: None.
-
User-Agent: Xnews/03.04.11
-
Xref: traf.lcs.mit.edu comp.lang.dylan:11908
This is a "I'm glad I used Dylan" story...
I wrote a program to download a few thousand web pages containing
information I needed, parse the pages for that information, and store
it in an ODBC database for later querying, data mining, etc.
The information on the pages had to be cross referenced with existing
database tables to ensure validity of data, making sure foreign keys
with code tables, dates, etc matched. I took this as a good opportunity
to use Dylan restarts and exceptions.
In the program I made sure exceptions were thrown whenever data from
the web pages did not match expected information in the database. For
each exception I created a restart protocol and made sure I had restart
handlers to allow correcting of the exceptions. Some of the exceptions
could be programatically fixed - so I had handlers that did this. An
example was where a lookup on a person's name failed. I had a handler
that tried soundex checking on the name to find a match and retry if
there was one with the new name.
There were a few cases where I couldn't have the program handle it or I
didn't think it worth it, so I specialised 'restart-query' on the
restart class to prompt for the correct information and made sure I had
a restart handler where the exception was signalled.
The program had been running for 10 hours and working fine. The
database was being populated and the automatic correction of exceptions
via the handlers worked well. Then up popped the Dylan exception error
message (in Functional Developer) saying that an exception had occurred
- no such record existed for a given date. Damn.
But in the list of available restarts in the Functional Developer debug
box, was the ability to choose a restart handler from those I'd made
available. Nicely printed in the list was the restart handlers I had in
scope:
- Enter data for missing record.
- Enter new date for current record.
I chose 'enter data for missing record', and my 'restart-query' method
was called prompting me to manually enter the missing data. I did this
and the program continued, completing two hours later.
The ability to create restart protocols and be able to choose them at
exception time, and prompt the user for correct values saved me *heaps*
of time. The ease of creating the restart mechanisms was a pleasant
surprise too.
Chris.
--
http://www.double.co.nz/dylan
Follow-Ups: