scsh-hackers
[Top] [All Lists]

[Scsh-hackers] [ scsh-Bugs-428193 ] handling host-info errors

To: noreply@sourceforge.net
Subject: [Scsh-hackers] [ scsh-Bugs-428193 ] handling host-info errors
From: noreply@sourceforge.net
Date: Mon, 28 May 2001 20:16:00 -0700
List-id: Discussion among the implementors <scsh-hackers.lists.sourceforge.net>
Sender: scsh-hackers-admin@lists.sourceforge.net
Bugs item #428193, was updated on 2001-05-28 20:15
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=110493&aid=428193&group_id=10493

Category: run-time
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Brian D. Carlstrom (bdc)
Assigned to: Brian D. Carlstrom (bdc)
Summary: handling host-info errors

Initial Comment:
From: brownb@ja.gs.com (Robert E. Brown)
To: scsh-news@zurich.ai.mit.edu
Subject: handling host-info errors
Date: 07 Feb 2000 12:29:35 -0500


I'm using scsh-0.5.2 on Linux.

When my scsh script calls the function socket-connect 
with a bad host name,
I get the following error

        Error: name->host-info: non-zero herrno ~s ~s
               1
               #f

since socket-connect calls host-info, which calls name-
>host-info, which
indicates a problem by calling the error function.

I'd like to handle this condition and print a 
reasonable error message that
the users of my script will understand.  I want some 
syntax like
with-errno-handler, but it should handle herror/host-
not-found.  I have not
yet located what I need in the manual.  Am I looking 
in the wrong spot?
What syntax should I be using?

                                bob



----------------------------------------------------------------------

>Comment By: Brian D. Carlstrom (bdc)
Date: 2001-05-28 20:16

Message:
Logged In: YES 
user_id=27364

From: Eric Marsden <emarsden@mail.dotcom.fr>
To: scsh-news@zurich.ai.mit.edu
Subject: Re: handling host-info errors
Date: 07 Feb 2000 20:40:32 +0100

>>>>> "reb" == Robert E Brown <brownb@ja.gs.com> writes:
  
  reb> I'd like to handle this condition and print a 
reasonable error
  reb> message that the users of my script will understand. 
I want
  reb> some syntax like with-errno-handler, but it should 
handle
  reb> herror/host-not-found.

I suppose that ideally there should be condition types 
instead of raw
errors for many of these things, but there would be a huge 
number of
them. Here is one way of intercepting specific error types:

#!/usr/local/bin/scsh \
-dm -m whnf -e main -s
!#

(define-structure whnf
  (export main)
  (open scheme scsh handle)
  (begin

    (define (with-host-not-found* thunk)
      (call-with-current-continuation
       (lambda (k)
         (with-handler
          (lambda (condition next)
            (cond ((string-match "^name->host-info" (cadr 
condition))
                   (display "No such host")
                   (newline)
                   (k))
                  (else (next))))
          thunk))))

    (define-syntax with-host-not-found
      (syntax-rules ()
        ((with-host-not-found ?body ...)
         (with-host-not-found* (lambda () ?body ...)))))

    (define (main args)
      (with-host-not-found
       (host-info "foo.bar.com")))))

--
Eric Marsden


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=110493&aid=428193&group_id=10493


<Prev in Thread] Current Thread [Next in Thread>