Solved

control The Exceptions

Posted on 2000-02-17
5
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2530530
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
ID: 2530546
can showmessage be displayed within web pages
0
 
LVL 15

Expert Comment

by:simonet
ID: 2531133
>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
ID: 2531147
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
ID: 2537737
Thanks geo:-).
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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