🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #2166

Re: How do I trap the exception

#2166
From: YangKai Liu
Date: Fri, 31 Oct 2003 05:11
29 lines
2335 bytes
If you get the "ugly" message in the debug mode, that is, to use the "Run" botton to execute your program, then you should try just build your project and execute your program outside BCB.  The message should then become the one you intended to throw to the user.

Cherie Jo Patenaude <patenaude1@llnl.gov> wrote:
>I'm using BCB 6.0 enterprise with TADOQuery to talk to a SQL Server
>database. I have added constraints on my tables to not allow duplicate
>entries into some of the tables. I have added a try ... exception clause
>around the update to trap the error, but I'm not getting the exception.
>Instead there is a message box from the inside the borland code with a
>fairly ugly message  --
>
>"Project CritLabel.exe raised exception class EOleException with message
>"Violation of UNIQUE KEY constraint "IX_Reflectors'. Canot insert
>duplicate key in object "Reflectors". Process stopped. Use Step or Run
>to continue."
>
>and it bounces me out of the save routine. I would prefer to trap the
>error myself, put out a more meaningful message and roll back the update
>in a more controlled manner. Do I have to set some sort of a flag or
>include some special code for the compiler to handle exceptions?
>
>The code I've used to test:
>    try {
>          RQuery->UpdateBatch(arAll);
>     } catch (Exception &e ) {
>          ShowMessage( "Exception found - "+e.message);
>          CSDatabase->RollbackTrans();
>          return;
>      }
>
Technical Details
Message-ID: <3fa1fcf9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed.freenet.de!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mail
References: <3F9DB12E.B1D3C42F@llnl.gov>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,8b125012df64bbe2
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-10-30 22:11:58 PST
From: "YangKai Liu" <yangkai.liu@burkelee.com>
Sender: "YangKai Liu" <yangkai.liu@burkelee.com>
Reply-To: "YangKai Liu" <yangkai.liu@burkelee.com>
Subject: Re: How do I trap the exception
Newsgroups: borland.public.cppbuilder.database.ado
X-User-Info: 61.222.26.93     
References:  <3F9DB12E.B1D3C42F@llnl.gov>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <3fa1fcf9$1@newsgroups.borland.com>
Date: 30 Oct 2003 22:11:05 -0700
X-Trace: newsgroups.borland.com 1067580665 207.105.83.66 (30 Oct 2003 22:11:05 -0700)
Lines: 31
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed.freenet.de!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mail