<HTML><BODY>Thank you. Yet one question^ is it possible to control, what will be in stacktrace.<br><br>Because, I have (macro generated) <br>(class base object%<br>   (define/public (write stream)<br>       (write-value l1 stream field1)<br>       (write-value l1 stream field2)<br>       (write-value l1 stream field3)<br>       ...))<br><br>Where l1 -- function, that takes its param and it to bytestream.<br><br><p>(class derived base<br>  (define/override (write stream)<br>     (super write stream)))<br><br>Then I have in stacktrace (super write stream), and then instantly body of l1. But no string "(write-value l1 stream field2)" where I could see, what field caouse error.<br>Is it possible to add it to stacktrace? Or how Racket decides, what expressions will be in stacktrace?</p><br><br><br>Wed, 17 Sep 2014 14:15:17 -0400 от Marc Burns <m4burns@uwaterloo.ca>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
        <div id="">
        



    









        
        


        
        
        
        
        

        
        

        
        



<div class="js-helper js-readmsg-msg">
        <style type="text/css"></style>
        <div>
                <base target="_self" href="https://e.mail.ru/">
                
                        <div id="style_14109777310000000733_BODY">It's not generally possible to edit the message contained in an<br>
exception. However, you can add information to the program's stack using<br>
continuation marks. Here's an example:<br>
<br>
(define my-cont-mark-key (gensym))<br>
<br>
(define (parse-item item)<br>
  (with-continuation-mark my-cont-mark-key item<br>
    ...))<br>
<br>
(with-handlers<br>
  ([exn? (lambda(e)<br>
           ((error-display-handler)<br>
            (format "Parser exception at item ~a:\n~a"<br>
                    (first<br>
                      (continuation-mark-set->list<br>
                        (exn-continuation-marks e)<br>
                        my-cont-mark-key))<br>
                    (exn-message e))<br>
            e))])<br>
  (parse-item start-item))<br>
<br>
The exception captures the continuation marks installed when it is<br>
thrown. You can extract the information you added to the stack with <br>
these marks in the exception handler.<br>
<br>
On Wed, Sep 17, 2014 at 08:59:15PM +0400, Roman Klochkov wrote:<br>
>  I'm writeing a parser.<br>
> So I want to see in parser exception what happend and when (not only where).<br>
> <br>
> (define (parse-item item)<br>
> ?? ??(with-handlers ([exn? (lambda (e) (raise (struct-copy exn e [message (format "At item ~a\n~a" item (exn-message e))])))])<br>
> ?? ?? ?? ?? ??....))<br>
> <br>
> But this way I lose all exception types. Is there a way to change exception message, saving its type, except long copy/paste like<br>
> (with-handlers ([exn:fail:contract:arity? (raise (struct-copy exn:fail:contract:arity ...))]<br>
> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??[exn:fil:contract? (raise??(struct-copy exn:fail:contract ...))]<br>
> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??...) <br>
> ?? ??...)<br>
> <br>
> ?<br>
> <br>
> -- <br>
> Roman Klochkov<br>
<br>
> ____________________<br>
>   Racket Users list:<br>
>   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</div>
                        
                
                <base target="_self" href="https://e.mail.ru/">
        </div>

        
</div>


</div>
</blockquote>
<br>
<br>-- <br>Roman Klochkov<br></BODY></HTML>