[Haskell-cafe] Re: How to catch error in array index when debugging

Colin Paul Adams colin at colina.demon.co.uk
Sun Mar 15 05:08:07 EDT 2009

>>>>> "Peter" == Peter Hercek <phercek at gmail.com> writes:

    Peter> Colin Paul Adams wrote:
    >>>>>>> "Adrian" == Adrian Neumann <aneumann at inf.fu-berlin.de>
    >>>>>>> writes:
    Adrian> You can use the ghci debugger
    >> >>
    >> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-
    Adrian> debugger.html
    Adrian> it can set breakpoints on exceptions.
    >> So i tried adding the -fbreak-on-error flag. It made no
    >> difference - it still exited:
    >> <interactive>: Error in array index <interactive>: interrupted
    >> <interactive>: warning: too many hs_exit()s

    Peter> IIRC, this is because you are catching exceptions at some
    Peter> higher level where you actually find out that this kind of
    Peter> an exception is not handled and give up. If your
    Peter> application is Gtk2Hs then this library will do the
    Peter> catching you do not like in this case.  Try to use

That is the case.

    Peter> -fbreak-on-exception instead of -fbreak-on-error. If you
    Peter> try this you may need to set break-on-exception late enough
    Peter> in the execution (use some breakpoint) so that you are not
    Peter> stopping at places which are ok (are correctly handled in
    Peter> an exception handler).

This works - in conhunction with :trace and :history. Thanks.
Colin Adams
Preston Lancashire

More information about the Haskell-Cafe mailing list