Solved

control The Exceptions

Posted on 2000-02-17
5
220 Views
Last Modified: 2010-04-04
i'am working Cgi App And i Recieve An Http Error...
Exception:EDataBaseError,how can i control any errors and display my own ErrMsg When it Occurs.
thanks.
0
Comment
Question by:mirghani
5 Comments
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
You can do something like this:

try
  // Do you stuff here
except // Oops, something bad happened
  on E : EDatabaseError do
    ShowMessage('An error occured during x'+#10#13+E.message);
end;

Cheers,

Raymond.
0
 

Author Comment

by:mirghani
Comment Utility
can showmessage be displayed within web pages
0
 
LVL 15

Expert Comment

by:simonet
Comment Utility
>can showmessage be displayed within web pages

No, you have to throw the error message in PageProducer.Contents

Alex
0
 
LVL 17

Accepted Solution

by:
geobul earned 30 total points
Comment Utility
Hi,

  In my programs I have a global string variable (MyError for example) where I can store multiline error description.
  With 'try...except' block in except part I assign a value to this variable and then send an error page as response.

Example:

procedure TDBModule.DBModuleWebActionItem2Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  MyError := '';
  Handled := False;
  try
    .......
  except
    on E : EDatabaseError do
      MyError := 'Database Error';
    on ...
  end;
  if MyError <> '' then begin
    Response.Content := '<HTML><BODY>'+MyError+</BODY></HTML>;
    Handled := True;
    Response.SendResponse;
  end;
end;

Actually, I use "Response.Content := ErrorPP.Content;" with PageProducer for custom error pages and a <#tag> for the error string.

Regards, Geo
0
 

Author Comment

by:mirghani
Comment Utility
Thanks geo:-).
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now