• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

control The Exceptions

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
mirghani
Asked:
mirghani
1 Solution
 
rwilson032697Commented:
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
 
mirghaniAuthor Commented:
can showmessage be displayed within web pages
0
 
simonetCommented:
>can showmessage be displayed within web pages

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

Alex
0
 
geobulCommented:
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
 
mirghaniAuthor Commented:
Thanks geo:-).
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now