/ Forside / Teknologi / Udvikling / Delphi/Pascal / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
Delphi/Pascal
#NavnPoint
oldwiking 603
jrossing 525
rpje 520
EXTERMINA.. 500
gandalf 460
gubi 270
DJ_Puden 250
PARKENSS 230
technet 210
10  jdjespers.. 200
OnException
Fra : Michael Vilhelmsen


Dato : 08-02-05 20:37

Hej

Jeg bruger Delphi 5 Ent.

Jeg har laver en procedure som overtager Application.OnException

Proceduren behandler nogle forskellige situationer mht. noget database
håndtering.
Proceduren ser sådan ud:

procedure TfrmMain.AppException(Sender: TObject; E: Exception);
begin
if E is EInOutError then
begin
CallError2('INPUT / OUTPUT TIL FILER
',E.Message,'','','','',0,0,E.HelpContext,FALSE,DMMain.trAlmindelig);
end
else if (E is EIBError) then
begin
CallError2('UKENDT DATABASE FEJL !',E.Message,'','','','',(E as
EIBError).SQLCode,(E as EIBError).IBErrorCode,(E as
EIBError).HelpContext,TRUE,DMTIB.IBTransaction1);
end
else
begin
CallError2('Ukendt fejl
!',E.Message,'','','','',0,0,E.HelpContext,FALSE,DMMain.trAlmindelig);
end;
end;



Mit problem er, at jeg faktisk KUN ønsker at min exception handler skal
vare disse og ingen andre.
Kan man på en eller anden måde få programmet til at fortsætte med sin
alm. exception handler ?


Håber I forstår mit spørgsmål


Michael

--
This is an automatic signature of MesNews.
Site : http://mesnews.no-ip.com


 
 
Ove Kjeldgaard (08-02-2005)
Kommentar
Fra : Ove Kjeldgaard


Dato : 08-02-05 21:22

Michael Vilhelmsen <Mivi_FJERN@FJERN_Hunderupnet.dk> wrote:

>Mit problem er, at jeg faktisk KUN ønsker at min exception handler skal
>vare disse og ingen andre.
>Kan man på en eller anden måde få programmet til at fortsætte med sin
>alm. exception handler ?

Hej Michael

Jeg har ikke nogen særlig ny Delphi på denne maskine, men det må være noget med
"Reraising an Exception"

Her er et lidt langt afsnit fra D2 hjælpen:

Sometimes when you handle an exception locally, you actually want to augment the
handling in the enclosing block, rather than replacing it. Of course, when your
local handler finishes its handling, it destroys the exception instance, so the
enclosing block's handler never gets to act. You can, however, prevent the
handler from destroying the exception, giving the enclosing handler a chance to
respond.
When an exception occurs, you might want to display some sort of message to the
user, then proceed with the standard handling. To do that, you declare a local
exception handler that displays the message then calls the reserved word raise.
If code in the { statements } part raises an exception, only the handler in the
outer except part executes. However, if code in the { special statements } part
raises an exception, the handling in the inner except part is executed, followed
by the more general handling in the outer except part.
By reraising exceptions, you can easily provide special handling for exceptions
in special cases without losing (or duplicating) the existing handlers.

Og det tilhørende eksempel:

The following example reraises an exception:

try
{ statements }
try
{ special statements }
except
on ESomething do
begin
{ handling for only the special statements }
raise;   { reraise the exception }
end;
end;
except
on ESomething do ...;   { handling you want in all cases }
end;

Jeg ved ikke om det er lige dette du søger, men mon det ellers ikke kan hjælpe
med at finde de rigtige udtryk?


--
Med venlig hilsen, Ove Kjeldgaard, nospam AT privat DOT dk
Natur og Friluftsliv: <http://hiker.dk>

Michael Vilhelmsen (08-02-2005)
Kommentar
Fra : Michael Vilhelmsen


Dato : 08-02-05 23:02

> The following example reraises an exception:
>
> try
> { statements }
> try
> { special statements }
> except
> on ESomething do
> begin
> { handling for only the special statements }
> raise;   { reraise the exception }
> end;
> end;
> except
> on ESomething do ...;   { handling you want in all cases }
> end;
>
> Jeg ved ikke om det er lige dette du søger, men mon det ellers ikke kan
> hjælpe med at finde de rigtige udtryk?


Jo - det er nok lidt der hen af.
Jeg har mange steder i mit program try - except dele.
Men andre steder har jeg ingen. Så sker det, at programmet alligevel
får en fej, hvor der ingen try - except er.
Denne fanger MIN exception handler så.
Heri er der nogle jeg gerne vil fange, og andre jeg bare gerne vil
"lade gå vidre" i systemet.

Michael

--
This is an automatic signature of MesNews.
Site : http://mesnews.no-ip.com


Michael Vilhelmsen (09-02-2005)
Kommentar
Fra : Michael Vilhelmsen


Dato : 09-02-05 09:39

Ove Kjeldgaard presented the following explanation :
> Michael Vilhelmsen <Mivi_FJERN@FJERN_Hunderupnet.dk> wrote:
>
>> Mit problem er, at jeg faktisk KUN ønsker at min exception handler skal
>> vare disse og ingen andre.
>> Kan man på en eller anden måde få programmet til at fortsætte med sin
>> alm. exception handler ?
>
> Hej Michael
>
> Jeg har ikke nogen særlig ny Delphi på denne maskine, men det må være noget med
> "Reraising an Exception"
>
> Her er et lidt langt afsnit fra D2 hjælpen:
>
> Sometimes when you handle an exception locally, you actually want to augment the
> handling in the enclosing block, rather than replacing it. Of course, when your
> local handler finishes its handling, it destroys the exception instance, so the
> enclosing block's handler never gets to act. You can, however, prevent the
> handler from destroying the exception, giving the enclosing handler a chance to
> respond.
> When an exception occurs, you might want to display some sort of message to the
> user, then proceed with the standard handling. To do that, you declare a local
> exception handler that displays the message then calls the reserved word raise.
> If code in the { statements } part raises an exception, only the handler in the
> outer except part executes. However, if code in the { special statements } part
> raises an exception, the handling in the inner except part is executed, followed
> by the more general handling in the outer except part.
> By reraising exceptions, you can easily provide special handling for exceptions
> in special cases without losing (or duplicating) the existing handlers.
>
> Og det tilhørende eksempel:
>
> The following example reraises an exception:
>
> try
> { statements }
> try
> { special statements }
> except
> on ESomething do
> begin
> { handling for only the special statements }
> raise;   { reraise the exception }
> end;
> end;
> except
> on ESomething do ...;   { handling you want in all cases }
> end;
>
> Jeg ved ikke om det er lige dette du søger, men mon det ellers ikke kan hjælpe
> med at finde de rigtige udtryk?



Fandt det.....

Application.ShowException gør præcis det jeg vil.

Takker for hjælpen.

Michael

--
==========
Best Regards / Venlig hilsen

Michael Vilhelmsen
This is an automatic signature of MesNews.
Site : http://mesnews.no-ip.com


Søg
Reklame
Statistik
Spørgsmål : 177459
Tips : 31962
Nyheder : 719565
Indlæg : 6408173
Brugere : 218881

Månedens bedste
Årets bedste
Sidste års bedste