More general tcp-connect error catching.

This commit is contained in:
Tony Garnock-Jones 2017-12-05 17:22:28 +00:00
parent c9ec9f6be9
commit eb564fdb7c
1 changed files with 9 additions and 10 deletions

View File

@ -111,16 +111,15 @@
(define (spawn-tcp-connection local-addr remote-addr)
(match-define (tcp-address remote-hostname remote-port) remote-addr)
(define-values (cin cout)
(with-handlers ([exn:fail:network? (lambda (e)
;; TODO: it'd be nice to
;; somehow communicate the
;; actual error to the local
;; peer.
(log-error "~a" (exn->string e))
(define o (open-output-string))
(close-output-port o)
(values (open-input-string "")
o))])
(with-handlers ([exn:fail? (lambda (e)
;; TODO: it'd be nice to somehow
;; communicate the actual error to
;; the local peer.
(log-error "~a" (exn->string e))
(define o (open-output-string))
(close-output-port o)
(values (open-input-string "")
o))])
(tcp:tcp-connect remote-hostname remote-port)))
(spawn-connection local-addr remote-addr cin cout))