Browse Source

* Call ShowRequestException when an exception occurs while handling a request

git-svn-id: trunk@12979 -
joost 16 years ago
parent
commit
78cd943947
2 changed files with 29 additions and 21 deletions
  1. 1 1
      packages/fcl-web/src/custfcgi.pp
  2. 28 20
      packages/fcl-web/src/custweb.pp

+ 1 - 1
packages/fcl-web/src/custfcgi.pp

@@ -12,7 +12,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-{ $define CGIDEBUG}
+{$define CGIDEBUG}
 {$mode objfpc}
 {$H+}
 

+ 28 - 20
packages/fcl-web/src/custweb.pp

@@ -205,28 +205,36 @@ Var
   MI : TModuleItem;
 
 begin
-  MC:=Nil;
-  M:=NIL;
-  If (OnGetModule<>Nil) then
-    OnGetModule(Self,ARequest,MC);
-  If (MC=Nil) then
-    begin
-    MN:=GetModuleName(ARequest);
-    If (MN='') and Not AllowDefaultModule then
-      Raise EFPWebError.Create(SErrNoModuleNameForRequest);
-    MI:=ModuleFactory.FindModule(MN);
-    If (MI=Nil) and (ModuleFactory.Count=1) then
-      MI:=ModuleFactory[0];
-    if (MI=Nil) then
+  try
+    MC:=Nil;
+    M:=NIL;
+    If (OnGetModule<>Nil) then
+      OnGetModule(Self,ARequest,MC);
+    If (MC=Nil) then
       begin
-      Raise EFPWebError.CreateFmt(SErrNoModuleForRequest,[MN]);
+      MN:=GetModuleName(ARequest);
+      If (MN='') and Not AllowDefaultModule then
+        Raise EFPWebError.Create(SErrNoModuleNameForRequest);
+      MI:=ModuleFactory.FindModule(MN);
+      If (MI=Nil) and (ModuleFactory.Count=1) then
+        MI:=ModuleFactory[0];
+      if (MI=Nil) then
+        begin
+        Raise EFPWebError.CreateFmt(SErrNoModuleForRequest,[MN]);
+        end;
+      MC:=MI.ModuleClass;
       end;
-    MC:=MI.ModuleClass;
-    end;
-  M:=FindModule(MC); // Check if a module exists already
-  If (M=Nil) then
-    M:=MC.Create(Self);
-  M.HandleRequest(ARequest,AResponse);
+    M:=FindModule(MC); // Check if a module exists already
+    If (M=Nil) then
+      M:=MC.Create(Self);
+    M.HandleRequest(ARequest,AResponse);
+  except
+    On E : Exception do
+      begin
+      ShowException(E);
+      ShowRequestException(AResponse,E);
+      end;
+  end;
 end;
 
 Procedure TCustomWebApplication.Initialize;