[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] catching errors in an app

From: ihaywood
Subject: Re: [Gnumed-devel] catching errors in an app
Date: Fri, 27 Jan 2006 10:55:11 +0800
User-agent: Internet Messaging Program (IMP) 3.2.1

Quoting Richard Terry <address@hidden>:
> BTW on the error topic, it just took me about 2.5 hours yesterday to import
> my 
> clinical demographic database into postgres. Brought home to me once again 
> how critical data input validation is in the first place. 
Like Karsten I believe the backend is the best/easiest place to do this.
gnumed's current problem is propagating these errors back to be user
in a nice way is harder than it should be. 

GUI-layer validation is nice as user functionality (not letting users type 
chars in the postcode fields, for example) but in terms of data validity
it's not the main game.

> I don't know what the CR character is (or if it is a combination in Dos 
> files), but I'd love a few line python routine which scans through the entire
> file and replaces the CR with a blank space - do in seconds what I took 
> manually (via going back to the access db table every time the record 
> crashed).
This is actually quite tough, because when is newline a "real" newline
or a false one inside a field.

You would need to count the pipes in each line and concatenate lines
with less than the proper number.

so something like:

l = list (file ("data").readlines ())
l.append ('')
n = 0
while n < len (n) and n[i]:
    if len (n[i].split('|')) < 20: # or whatever the number of fields is
       n[i] += n[i+1]
       del n[i+1]
       n += 1

f= file ("data", "w")
for i in l:
   f.write (i+'\n')
f.close ()

> This also raises the question of allowing multi-line text inputs in say the 
> street field I guess.
No, street names are street names - one line.
There's an "addendum" field in the address table for all the extra address
stuff, IMHO this (and only this) field should be able to have newlines.
> I would wlecome your comments on all this.
> ==============================
> Richard Terry wrote:
> > This is probably more pythonic than wx, however:
> > 
> > Now that I (sort of) have a functional app (my drug browser), how does one
> go 
> > about catching the invetible errors.
> > 
> > Does one have a global error handler, or does one error trap in every 
> > subroutine?
> > 
> > Any examples/pointers to code etc would be welcomed.
> Currently exceptions are not passed through the C++ layers so if you 
> want to catch them you need to do it in each event handler or callback.
We already knew this.
The problem is in Python, everything is an exception, even syntax errors,
which are silently gobbled by the wxPython core, unless you provide
an exception handler.

Personally want I'd like to see is a single generic handler at the top
of the stack (so called from the GUI event handler) which writes to the log 
and presents a sensible dialog box to the user. 99.99% of the time this is the 
only sensible thing to do anyway, this simplifies the rest of the code 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]