RB exception handling (was Re: Re[2]: Trap Valentina license time limit)

Thorsten Hohage thohage at objectmanufactur.com
Sat Jul 7 03:43:09 CDT 2007


Hi Barry,

On 2007-07-07, at 09:28, Barry G. Sumpter wrote:

> Yes, thanks for that the
> Exception exc as VException
>
> Is easy enough to understand.
>
> The context was related to the database erroring out and me not  
> knowing what
> the error was and once the error was found then what other errors  
> should I
> be checking for in the same context etc.
>
> And thinking why not just have a single routine that checks thru  
> all errors
> and displays a standard format dialog etc.

You've got a "factory" build method for that already in REALbasic.

In your app-class there is a

	UnhandledException(error as RuntimeException) As Boolean

where you can catch ALL Exceptions and display a dialog box or what  
ever you want.

But of course this should only be a 2nd parachute for security. My  
IMHO or better my philosophy is, it should never happen an exception,  
so I check a lot of thing BEFORE they can happen i.e. checking nil  
value. Others may see it in other way,  "why should I write hundreds  
of is's, when I can catch the exception later?".

I recommend to handle exception as fast as possible. So if you use a  
ValentinaDB-Object and not handle db-access all over your code, than  
you can handle all valentina-exceptions in one place. And giving your  
users a much better experience. I.e. you catch these timeout, then  
you display a dialog box, but also save the current command(s) to  
file. After restart your app detects the saved file and asked "There  
are unfinished db-operations, do you want them to be executed now?"  
and everything goes on like nothing happened.


I hope THIS was the answer to your question or better an answer you  
want to hear and that help you to go further.

regards

Thorsten Hohage
--
objectmanufactur.com - Hamburg,Germany




More information about the Valentina mailing list