Re: crash_routine()

new topic     » goto parent     » topic index » view thread      » older message » newer message

CoJaBo wrote:
> crash_routine()
> 
> Possible bug:
> 1. A routine id should only be added once.
> If it is added a second time it should
> be ignored, not called twice.

Is it that hard for you to avoid adding it a second time?

Maybe someone will want to call the same handler a second time.
 
> Changes:
> 1. If a crash routine crashes, Euphoria
> should write debug info to
> ex_{crash handler function name}.err
> and then continue with the rest of the
> crash routines.
> Example:
> }}}
<eucode>
> include machine.e
> 
> function save_all_user_data(object x)
> puts(1,"Saving data...")
> return 0
> end function
> 
> crash_routine(routine_id("save_all_user_data"))
> 
> function save_debug_info(object x)
> integer f
> f=open("bad file name:","w")
> puts(f,"test")
> return 0
> end function
> 
> crash_routine(routine_id("save_debug_info"))
> 
> ?1/0
> </eucode>
{{{

> Currently, save_all_user_data() would never be called.

The case where you have two or more crash handlers,
and one fails, should be pretty rare,
other than when you are first debugging the handlers.
You can see from ex_crash.err which handler crashed.
Proceeding with the next handler may or may not be a good
thing to do. I'm not going to do anything fancy in this case.
 
> 2. The parameter to the crash routine should contain
> (at least):
> The error text that would be displayed.

I'm considering that idea, although you could read the message,
and lots of other stuff, from ex.err.

> A constant for the error that occered(like EC_DIV_BY_0).

I'm reluctant to create a system of error codes.
It encourages maintainers to re-use a standard
error message, rather than writing a new message
tailored to the specific thing that went wrong. Everything
becomes "SYNTAX ERROR", or "SUBSCRIPT ERROR" etc.
Also, you can no longer see the message in the source code
at the point where the error is detected. You instead see an
error number, perhaps as a defined constant.
 
> 3. There should be a way to turn off all the errors that
> Eu displays, allowing a crash handler to display a nicer
> one, or even e-mail the error.

crash_file("") 
will suppress error diagnostics from going to the screen,
and will also suppress any ex.err from being created.

crash_message("") 
will suppress error diagnostics from going to the screen,
but will allow ex.err to be created.

Thanks,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu