Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 205135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:31:47+00:00 2026-05-11T17:31:47+00:00

In some Delphi 7 code I am maintaining, I’ve noticed a lot of instances

  • 0

In some Delphi 7 code I am maintaining, I’ve noticed a lot of instances of the following:

with ADOQuery1 do begin
  // .. fill out sql.text, etc
  try
    execSQL;
  except
    raise;
  end;
end;

It seems to me that these try blocks could be removed, since they do nothing. However, I am wary of possible subtle side-effects..

Can anyone think of any instances in which these blocks could actually do anything that wouldn’t happen without them there?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:31:47+00:00Added an answer on May 11, 2026 at 5:31 pm

    In this context, the raise operation has no effect and should be removed becuase its simply re-raising the exception that the exception block just caught. raise is typically used to transfer control to the end of the block when no appropriate error handling is available. In the following we handle the custom exception, but any other exception should be handled elsewhere.

    try
      someOperation;
    except
      on e: ECustomException do
        SomeCustomHandelr;
      else
         begin
           // the raise is only useful to rethrow the exception to an encompasing 
           // handler.  In this case after I have called my logger code. as Rob
           // mentioned this can be omitted if you arent handling anything because
           // the compiler will simply jump you to the next block if there is no
           // else.
           LogUnexpectedException('some operation failed',e);
           raise;
         end;
    end;
    

    Be careful that there is similar looking form without the “raise” that DOES have the side effect of eating/hiding any exceptions. practicies by very unscrupulous developers who have hopefully moved on to positions with the competition.

    with ADOQuery1 do begin  
      // .. fill out sql.text, etc  
      try    
        execSQL; 
      except
        // no handler so this just eats any "errors"    
      end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking at some code (Delphi 7) with following check is at the
consider the following delphi pascal code: var tc: TComponent begin { do something to
I have the following Delphi code: destructor TXX_XXXX.Destroy; var i: Integer; begin if Assigned(Allocations)
I copied some Delphi code from one project to another, and found that it
Ok, this is a curly one. I'm working on some Delphi code that I
We have some ancient Delphi code (might have even originated as Turbo Pascal code)
I was looking into using some .NET code from within a Delphi program, I
Two Delphi programs need to load foo.dll, which contains some code that injects a
Im trying to convert some Delphi code to c# and I've come across a
I am a complete beginner here. Can someone please post some Delphi code to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.