CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007
    Posts
    38

    Post handling exception

    Hi Guys,
    I have bumped into an issue today, as I wanted to make my process better in Fault Tolerance(FT)
    I have a tray block trying to execute some sqls, and if any exception is thrown (due to an issue in the DB side), I want to hang for a while and retry the same execution, rather give an error warning and forget. bcoz the later will cause some data not stored to DB properly. If the exception is due to a disconnection, I'll have to retry to connect for ever. (This window can be used to fix the DB issues, and imediately my program should move forward).

    I'm thinking of the following structure. but not sure this is a good practice. can any one please help?
    Code:
    while(true)
      try{
         handle.execute("INSERT.....");
         break;
      }
      catch(Exception::Connect& e){
          sleep(10);
          reconnect();
      }
      catch(Exception::Execute& e) {
         sleep(10);
      }
    }
    Last edited by skanthaverl; April 16th, 2008 at 08:34 AM.
    Regards
    sris kanagasabai

  2. #2
    Join Date
    Sep 2007
    Location
    poland|wrocław
    Posts
    47

    Re: handling exception

    Hi, IMHO thats not to bad as it looks
    You could try also something similiar:
    Code:
    while(true)
      try{
         handle.execute("INSERT.....");
         break;
      }
      catch( DB_Exc& e )
      {
        <pseudo_code>
        StartAnotherThread
        SynchronizeThreads
        DiagnoseTheProblem
        IfYouCanTryAgain()
            OK_LetsTryAgain
        else
            NO_NotifyUser
            Break
        </pseudo>     
      }
    }

  3. #3
    Join Date
    Jul 2007
    Posts
    38

    Re: handling exception

    Hi macabre13,
    thanks for your thoughts.
    Regards
    sris kanagasabai

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured