[racket] tcp-read handlers
To supplement Matthew's response, see exn style:
http://plt.eecs.northwestern.edu/snapshots/current/doc/style/Choosing_the_Right_Construct.html#%28part._.Exceptions%29
This does not address the problem part.
On Jan 18, 2014, at 11:04 AM, Matthew Flatt wrote:
> The `exn?` predicate would catch all exceptions from the base
> libraries.[*]
>
> I think the problem may be that the underlying TCP port is read in a
> separate decoding thread, and so the exception and printing happens in
> that thread. If I'm right, then that seems like a flaw in our
> implementation of decoding.
>
> [*] To avoid interfering with the `exn:break?` exceptions triggered by
> Ctl-C, you almost always want `exn:fail?` instead of just `exn?`.
>
> At Sat, 18 Jan 2014 09:50:15 -0200, Eduardo Bellani wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Is there a way to install a handler for the tcp-error exception?
>> I have a function like this
>>
>> (define (get-page link-url (max-tries 5))
>> (let loop ([current-try 0])
>> (with-handlers ([exn?
>> (? (e)
>> (if (> current-try max-tries)
>> (error 'get-page
>> "failed because it exceeded ~a tries"
>> max-tries)
>> (begin (sleep 2)
>> (loop (add1 current-try)))))])
>> (get-pure-port link-url))))
>>
>> that I'm using to crawl some data, but sometimes it's printing:
>>
>> tcp-read: error reading
>> system error: Connection reset by peer; errno=104
>> context...:
>> /usr/racket/collects/net/url.rkt:392:3
>>
>> Thanks for the attention.
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.14 (GNU/Linux)
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iEYEARECAAYFAlLaanUACgkQSbLl0kCTjGkm+ACbBSMyUuY4NOYjdLMgba/OJAFc
>> 8OYAn0NkLMKLLma/MxAeEFMLtnrMekOY
>> =aAUJ
>> -----END PGP SIGNATURE-----
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users