Loading ...
Sorry, an error occurred while loading the content.

RE: [eiffel_software] Server/Client problems

Expand Messages
  • rfo@amalasoft.com
    Hello Wyden! I guess I have to answer your question with another question. How do you know it doesn t work? Typically, one would check the nature of the
    Message 1 of 5 , Mar 1, 2009
    • 0 Attachment
      Hello Wyden!

      I guess I have to answer your question with another question.
      How do you know it doesn't work?
      Typically, one would check the nature of the exception in this case.
      There might be a different reason for the exception than the one you
      expect. You can, for example, check to see if it's a signal exception
      and do one thing, but if it's an IO exception, do another, etc. Have a
      look at the EXCEPTIONS class.

      The retries are excecuted immediately, so there is little chance of
      things changing in between attempts.
      To introduce delays, you would use a layer above the open/read routine
      that waits between attempts and checks the result of each, putting in a
      sleep or equivalent.

      f1
      local
      tries: INTEGER
      do
      from f2
      until done or gave_up
      loop
      if not done then
      tries := tries + 1
      if tries > max_tries then
      -- give up
      else
      -- delay
      f2
      end
      end
      end
      end

      f2
      do
      -- do something
      rescue
      -- test for exception, restore+retry if desired
      end

      R

      ==================================================
      Roger F. Osmond
      ----------------------------------------
      Amalasoft Corporation
      273 Harwood Avenue
      Littleton, MA 01460

      > -------- Original Message --------
      > Subject: Re: [eiffel_software] Server/Client problems
      > From: Wyden Silvan <wydensaas@...>
      > Date: Sun, March 01, 2009 1:15 am
      > To: eiffel_software@yahoogroups.com
      > Hello Roger
      > Thanks for your answer. I know that the example was not very good. But my aime was to understand the mechanisme of the eiffel fault managment with rescue and retry. Is there any good documentation about that?
      > We are getting away from the main subject. My problem is that there always apears an error when I tried to connect via TCP/IP to a server that isn't up. I make the connection via the NETWORK_STRAM_SOCKET and with the feature connect. And there is a rescue and retry mechanisme but why doens't it work?
      > Hope that somebody can help me.
      > Regards Wyden S.
      > ________________________________
      > From: "rfo@..." <rfo@...>
      > To: eiffel_software@yahoogroups.com
      > Sent: Saturday, February 28, 2009 3:15:16 PM
      > Subject: RE: [eiffel_software] Server/Client problems
      > Hello Wyden!
      > If you know the file does not exist at that point (you don't really, but
      > that's a separate issue), why are you trying again?
      > I think you must be taking the example too literally.
      > If what you want is to fail gracefully when an expected file does not
      > exists, then simply report that and fall through to exit.
      > If what you want is to check for the existence of a file for some normal
      > logic path, then use your logic, not the exception mechanism.
      > It is not uncommon for some programmers to blur the distinction between
      > exceptions and normal logic. Please don't do that. If you think of an
      > exception as something that _should_ never happen, but still might, then
      > you are on the right track. This example is not very good in that
      > regard, but it has the benefit of being fairly simple.
      > If there is a chance that the subsequent attempts to read that file will
      > succeed, you can use the retry mechanism, but count the retries until
      > you give up.
      > If there is no chance that subsequent attempts will succeed, then do not
      > use retry. Simply print out your error message and go home.
      > It's all much less mysterious than it appears at first, really.
      > Now, if you want to be able to continue operation after failing to open
      > the file, then change you logic to create that file object without the
      > open_read, using simply 'make'. Then check for file.exists, and _then_
      > file.is_readable. At that point you have a pretty good idea that the
      > file can be opened for reading, and you can call open_read. If the read
      > fails at that time, you have a genuine exception.
      > R
      > ============ ========= ========= ========= ========= ==
      > Roger F. Osmond
      > ------------ --------- --------- --------- -
      > Amalasoft Corporation
      > 273 Harwood Avenue
      > Littleton, MA 01460
      > > -------- Original Message --------
      > > Subject: Re: [eiffel_software] Server/Client problems
      > > From: Wyden Silvan <wydensaas@yahoo. com>
      > > Date: Sat, February 28, 2009 3:01 am
      > > To: eiffel_software@ yahoogroups. com
      > > Thanks for the answer.
      > > So what can I for example do when I want to open a textfile and it doesn't exists? So I will become back an error that the file doesn't exists. But for the enduser it's not very nice to become an execption trace. I know that I can check if the file exists or not. But how can I do such a thing with rescue?
      > > I have tried the following code (I have found the basics on eiffelroom.org) :
      > > make is
      > >    local
      > >      l_no_retry: BOOLEAN
      > >      file: PLAIN_TEXT_FILE
      > >    do
      > >     if not l_no_retry then
      > >       --Try code here
      > >       create file.make_open_ read ("test2.txt" )
      > >     end
      > >     l_no_retry := true
      > >    
      > >     -- Finally code here
      > >     io.put_string ("File does exists")
      > >    rescue
      > >      if not l_no_retry then
      > >       
      > >        -- Catch code here
      > >        io.put_string ("File doesn't exists")
      > >        l_no_retry := true
      > >        retry
      > >      end
      > >    end
      > > I hope that somebody can help me.
      > > Regards
      > > Wyden S.
      > > ____________ _________ _________ __
      > > From: Peter Gummer <p-gummer@bigpond. net.au>
      > > To: eiffel_software@ yahoogroups. com
      > > Sent: Friday, February 27, 2009 1:17:51 PM
      > > Subject: Re: [eiffel_software] Server/Client problems
      > > Wyden Silvan wrote:
      > > > Is there something in Eiffel like "try" and "catch"?
      > > >
      > > Yes. Look up "rescue" and "retry". You'll need to read about it, because
      > > it's designed to work with Design by Contract, so it works differently
      > > from the structured exception handling that you are probably used to in
      > > other languages.
      > > The basic pattern you might use is something like this:
      > > my_routine
      > > local
      > > retrying: BOOLEAN
      > > do
      > > if not retrying then
      > > -- Do something that might raise an exception
      > > end
      > > rescue
      > > -- Handle the exception
      > > retrying := True
      > > retry
      > > end
      > > There's a lot of information describing "rescue". You can read that and
      > > then ask if you have some questions.
      > > - Peter Gummer
      > >
      > > [Non-text portions of this message have been removed]
      >
      > [Non-text portions of this message have been removed]
    • Wyden Silvan
      Hallo Roger Thanks for your answer. But I don t want any retries. I only want to have my own error message after the IO exception. I don t want that the window
      Message 2 of 5 , Mar 2, 2009
      • 0 Attachment
        Hallo Roger

        Thanks for your answer. But I don't want any retries. I only want to have my own error message after the IO exception. I don't want that the window from eiffel with the "ignore" and "quit" button comes.

        Regards

        Wyden S.




        ________________________________
        From: "rfo@..." <rfo@...>
        To: eiffel_software@yahoogroups.com
        Sent: Sunday, March 1, 2009 2:08:48 PM
        Subject: RE: [eiffel_software] Server/Client problems


        Hello Wyden!

        I guess I have to answer your question with another question.
        How do you know it doesn't work?
        Typically, one would check the nature of the exception in this case.
        There might be a different reason for the exception than the one you
        expect. You can, for example, check to see if it's a signal exception
        and do one thing, but if it's an IO exception, do another, etc. Have a
        look at the EXCEPTIONS class.

        The retries are excecuted immediately, so there is little chance of
        things changing in between attempts.
        To introduce delays, you would use a layer above the open/read routine
        that waits between attempts and checks the result of each, putting in a
        sleep or equivalent.

        f1
        local
        tries: INTEGER
        do
        from f2
        until done or gave_up
        loop
        if not done then
        tries := tries + 1
        if tries > max_tries then
        -- give up
        else
        -- delay
        f2
        end
        end
        end
        end

        f2
        do
        -- do something
        rescue
        -- test for exception, restore+retry if desired
        end

        R

        ============ ========= ========= ========= ========= ==
        Roger F. Osmond
        ------------ --------- --------- --------- -
        Amalasoft Corporation
        273 Harwood Avenue
        Littleton, MA 01460

        > -------- Original Message --------
        > Subject: Re: [eiffel_software] Server/Client problems
        > From: Wyden Silvan <wydensaas@yahoo.. com>
        > Date: Sun, March 01, 2009 1:15 am
        > To: eiffel_software@ yahoogroups. com
        > Hello Roger
        > Thanks for your answer. I know that the example was not very good. But my aime was to understand the mechanisme of the eiffel fault managment with rescue and retry. Is there any good documentation about that?
        > We are getting away from the main subject. My problem is that there always apears an error when I tried to connect via TCP/IP to a server that isn't up. I make the connection via the NETWORK_STRAM_ SOCKET and with the feature connect. And there is a rescue and retry mechanisme but why doens't it work?
        > Hope that somebody can help me.
        > Regards Wyden S.
        > ____________ _________ _________ __
        > From: "rfo@amalasoft. com" <rfo@amalasoft. com>
        > To: eiffel_software@ yahoogroups. com
        > Sent: Saturday, February 28, 2009 3:15:16 PM
        > Subject: RE: [eiffel_software] Server/Client problems
        > Hello Wyden!
        > If you know the file does not exist at that point (you don't really, but
        > that's a separate issue), why are you trying again?
        > I think you must be taking the example too literally.
        > If what you want is to fail gracefully when an expected file does not
        > exists, then simply report that and fall through to exit.
        > If what you want is to check for the existence of a file for some normal
        > logic path, then use your logic, not the exception mechanism.
        > It is not uncommon for some programmers to blur the distinction between
        > exceptions and normal logic. Please don't do that. If you think of an
        > exception as something that _should_ never happen, but still might, then
        > you are on the right track. This example is not very good in that
        > regard, but it has the benefit of being fairly simple.
        > If there is a chance that the subsequent attempts to read that file will
        > succeed, you can use the retry mechanism, but count the retries until
        > you give up.
        > If there is no chance that subsequent attempts will succeed, then do not
        > use retry. Simply print out your error message and go home.
        > It's all much less mysterious than it appears at first, really.
        > Now, if you want to be able to continue operation after failing to open
        > the file, then change you logic to create that file object without the
        > open_read, using simply 'make'. Then check for file.exists, and _then_
        > file.is_readable. At that point you have a pretty good idea that the
        > file can be opened for reading, and you can call open_read. If the read
        > fails at that time, you have a genuine exception.
        > R
        > ============ ========= ========= ========= ========= ==
        > Roger F. Osmond
        > ------------ --------- --------- --------- -
        > Amalasoft Corporation
        > 273 Harwood Avenue
        > Littleton, MA 01460
        > > -------- Original Message --------
        > > Subject: Re: [eiffel_software] Server/Client problems
        > > From: Wyden Silvan <wydensaas@yahoo. com>
        > > Date: Sat, February 28, 2009 3:01 am
        > > To: eiffel_software@ yahoogroups. com
        > > Thanks for the answer.
        > > So what can I for example do when I want to open a textfile and it doesn't exists? So I will become back an error that the file doesn't exists. But for the enduser it's not very nice to become an execption trace. I know that I can check if the file exists or not. But how can I do such a thing with rescue?
        > > I have tried the following code (I have found the basics on eiffelroom.org) :
        > > make is
        > >    local
        > >      l_no_retry: BOOLEAN
        > >      file: PLAIN_TEXT_FILE
        > >    do
        > >     if not l_no_retry then
        > >       --Try code here
        > >       create file.make_open_ read ("test2.txt" )
        > >     end
        > >     l_no_retry := true
        > >    
        > >     -- Finally code here
        > >     io.put_string ("File does exists")
        > >    rescue
        > >      if not l_no_retry then
        > >       
        > >        -- Catch code here
        > >        io.put_string ("File doesn't exists")
        > >        l_no_retry := true
        > >        retry
        > >      end
        > >    end
        > > I hope that somebody can help me.
        > > Regards
        > > Wyden S.
        > > ____________ _________ _________ __
        > > From: Peter Gummer <p-gummer@bigpond. net.au>
        > > To: eiffel_software@ yahoogroups. com
        > > Sent: Friday, February 27, 2009 1:17:51 PM
        > > Subject: Re: [eiffel_software] Server/Client problems
        > > Wyden Silvan wrote:
        > > > Is there something in Eiffel like "try" and "catch"?
        > > >
        > > Yes. Look up "rescue" and "retry". You'll need to read about it, because
        > > it's designed to work with Design by Contract, so it works differently
        > > from the structured exception handling that you are probably used to in
        > > other languages.
        > > The basic pattern you might use is something like this:
        > > my_routine
        > > local
        > > retrying: BOOLEAN
        > > do
        > > if not retrying then
        > > -- Do something that might raise an exception
        > > end
        > > rescue
        > > -- Handle the exception
        > > retrying := True
        > > retry
        > > end
        > > There's a lot of information describing "rescue". You can read that and
        > > then ask if you have some questions.
        > > - Peter Gummer
        > >
        > > [Non-text portions of this message have been removed]
        >
        > [Non-text portions of this message have been removed]


        __.._,_.___
        Messages in this topic (3) Reply (via web post) | Start a new topic
        Messages
        MARKETPLACE

        ________________________________
        From kitchen basics to easy recipes - join the Group from Kraft Foods

        Change settings via the Web (Yahoo! ID required)
        Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
        Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
        Recent Activity
        *  6
        New MembersVisit Your Group
        Yahoo! Finance
        It's Now Personal
        Guides, news,
        advice & more.
        Search Ads
        Get new customers.
        List your web site
        in Yahoo! Search.
        Group Charity
        One Economy
        Helping close the
        digital divide
        .






        [Non-text portions of this message have been removed]
      • rfo@amalasoft.com
        Hello Wyden! Then what you want is easier. Simply define a top-level rescue clause, write the exception trace to a file (see the EXCEPTIONS class; it s a
        Message 3 of 5 , Mar 2, 2009
        • 0 Attachment
          Hello Wyden!

          Then what you want is easier.
          Simply define a top-level rescue clause, write the exception trace to a
          file (see the EXCEPTIONS class; it's a single query), and exit. Do not
          use the retry mechanism at all. The default exception handling will be
          avoided that way.

          R

          ==================================================
          Roger F. Osmond
          ----------------------------------------
          Amalasoft Corporation
          273 Harwood Avenue
          Littleton, MA 01460

          > -------- Original Message --------
          > Subject: Re: [eiffel_software] Server/Client problems
          > From: Wyden Silvan <wydensaas@...>
          > Date: Mon, March 02, 2009 1:49 pm
          > To: eiffel_software@yahoogroups.com
          > Hallo Roger
          > Thanks for your answer. But I don't want any retries. I only want to have my own error message after the IO exception. I don't want that the window from eiffel with the "ignore" and "quit" button comes.
          > Regards
          > Wyden S.
          > ________________________________
          > From: "rfo@..." <rfo@...>
          > To: eiffel_software@yahoogroups.com
          > Sent: Sunday, March 1, 2009 2:08:48 PM
          > Subject: RE: [eiffel_software] Server/Client problems
          > Hello Wyden!
          > I guess I have to answer your question with another question.
          > How do you know it doesn't work?
          > Typically, one would check the nature of the exception in this case.
          > There might be a different reason for the exception than the one you
          > expect. You can, for example, check to see if it's a signal exception
          > and do one thing, but if it's an IO exception, do another, etc. Have a
          > look at the EXCEPTIONS class.
          > The retries are excecuted immediately, so there is little chance of
          > things changing in between attempts.
          > To introduce delays, you would use a layer above the open/read routine
          > that waits between attempts and checks the result of each, putting in a
          > sleep or equivalent.
          > f1
          > local
          > tries: INTEGER
          > do
          > from f2
          > until done or gave_up
          > loop
          > if not done then
          > tries := tries + 1
          > if tries > max_tries then
          > -- give up
          > else
          > -- delay
          > f2
          > end
          > end
          > end
          > end
          > f2
          > do
          > -- do something
          > rescue
          > -- test for exception, restore+retry if desired
          > end
          > R
          > ============ ========= ========= ========= ========= ==
          > Roger F. Osmond
          > ------------ --------- --------- --------- -
          > Amalasoft Corporation
          > 273 Harwood Avenue
          > Littleton, MA 01460
          > > -------- Original Message --------
          > > Subject: Re: [eiffel_software] Server/Client problems
          > > From: Wyden Silvan <wydensaas@yahoo.. com>
          > > Date: Sun, March 01, 2009 1:15 am
          > > To: eiffel_software@ yahoogroups. com
          > > Hello Roger
          > > Thanks for your answer. I know that the example was not very good. But my aime was to understand the mechanisme of the eiffel fault managment with rescue and retry. Is there any good documentation about that?
          > > We are getting away from the main subject. My problem is that there always apears an error when I tried to connect via TCP/IP to a server that isn't up. I make the connection via the NETWORK_STRAM_ SOCKET and with the feature connect. And there is a rescue and retry mechanisme but why doens't it work?
          > > Hope that somebody can help me.
          > > Regards Wyden S.
          > > ____________ _________ _________ __
          > > From: "rfo@amalasoft. com" <rfo@amalasoft. com>
          > > To: eiffel_software@ yahoogroups. com
          > > Sent: Saturday, February 28, 2009 3:15:16 PM
          > > Subject: RE: [eiffel_software] Server/Client problems
          > > Hello Wyden!
          > > If you know the file does not exist at that point (you don't really, but
          > > that's a separate issue), why are you trying again?
          > > I think you must be taking the example too literally.
          > > If what you want is to fail gracefully when an expected file does not
          > > exists, then simply report that and fall through to exit.
          > > If what you want is to check for the existence of a file for some normal
          > > logic path, then use your logic, not the exception mechanism.
          > > It is not uncommon for some programmers to blur the distinction between
          > > exceptions and normal logic. Please don't do that. If you think of an
          > > exception as something that _should_ never happen, but still might, then
          > > you are on the right track. This example is not very good in that
          > > regard, but it has the benefit of being fairly simple.
          > > If there is a chance that the subsequent attempts to read that file will
          > > succeed, you can use the retry mechanism, but count the retries until
          > > you give up.
          > > If there is no chance that subsequent attempts will succeed, then do not
          > > use retry. Simply print out your error message and go home.
          > > It's all much less mysterious than it appears at first, really.
          > > Now, if you want to be able to continue operation after failing to open
          > > the file, then change you logic to create that file object without the
          > > open_read, using simply 'make'. Then check for file.exists, and _then_
          > > file.is_readable. At that point you have a pretty good idea that the
          > > file can be opened for reading, and you can call open_read. If the read
          > > fails at that time, you have a genuine exception.
          > > R
          > > ============ ========= ========= ========= ========= ==
          > > Roger F. Osmond
          > > ------------ --------- --------- --------- -
          > > Amalasoft Corporation
          > > 273 Harwood Avenue
          > > Littleton, MA 01460
          > > > -------- Original Message --------
          > > > Subject: Re: [eiffel_software] Server/Client problems
          > > > From: Wyden Silvan <wydensaas@yahoo. com>
          > > > Date: Sat, February 28, 2009 3:01 am
          > > > To: eiffel_software@ yahoogroups. com
          > > > Thanks for the answer.
          > > > So what can I for example do when I want to open a textfile and it doesn't exists? So I will become back an error that the file doesn't exists. But for the enduser it's not very nice to become an execption trace. I know that I can check if the file exists or not. But how can I do such a thing with rescue?
          > > > I have tried the following code (I have found the basics on eiffelroom.org) :
          > > > make is
          > > >    local
          > > >      l_no_retry: BOOLEAN
          > > >      file: PLAIN_TEXT_FILE
          > > >    do
          > > >     if not l_no_retry then
          > > >       --Try code here
          > > >       create file.make_open_ read ("test2.txt" )
          > > >     end
          > > >     l_no_retry := true
          > > >    
          > > >     -- Finally code here
          > > >     io.put_string ("File does exists")
          > > >    rescue
          > > >      if not l_no_retry then
          > > >       
          > > >        -- Catch code here
          > > >        io.put_string ("File doesn't exists")
          > > >        l_no_retry := true
          > > >        retry
          > > >      end
          > > >    end
          > > > I hope that somebody can help me.
          > > > Regards
          > > > Wyden S.
          > > > ____________ _________ _________ __
          > > > From: Peter Gummer <p-gummer@bigpond. net.au>
          > > > To: eiffel_software@ yahoogroups. com
          > > > Sent: Friday, February 27, 2009 1:17:51 PM
          > > > Subject: Re: [eiffel_software] Server/Client problems
          > > > Wyden Silvan wrote:
          > > > > Is there something in Eiffel like "try" and "catch"?
          > > > >
          > > > Yes. Look up "rescue" and "retry". You'll need to read about it, because
          > > > it's designed to work with Design by Contract, so it works differently
          > > > from the structured exception handling that you are probably used to in
          > > > other languages.
          > > > The basic pattern you might use is something like this:
          > > > my_routine
          > > > local
          > > > retrying: BOOLEAN
          > > > do
          > > > if not retrying then
          > > > -- Do something that might raise an exception
          > > > end
          > > > rescue
          > > > -- Handle the exception
          > > > retrying := True
          > > > retry
          > > > end
          > > > There's a lot of information describing "rescue". You can read that and
          > > > then ask if you have some questions.
          > > > - Peter Gummer
          > > >
          > > > [Non-text portions of this message have been removed]
          > >
          > > [Non-text portions of this message have been removed]
          > __.._,_.___
          > Messages in this topic (3) Reply (via web post) | Start a new topic
          > Messages
          > MARKETPLACE
          > ________________________________
          > From kitchen basics to easy recipes - join the Group from Kraft Foods
          >
          > Change settings via the Web (Yahoo! ID required)
          > Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
          > Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
          > Recent Activity
          > *  6
          > New MembersVisit Your Group
          > Yahoo! Finance
          > It's Now Personal
          > Guides, news,
          > advice & more.
          > Search Ads
          > Get new customers.
          > List your web site
          > in Yahoo! Search.
          > Group Charity
          > One Economy
          > Helping close the
          > digital divide
          > .
          >
          > [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.