a bunch of bufixes and also a new ServletModuleUserException so that we
[mir.git] / source / mir / servlet / ServletModuleDispatch.java
index de5d86d..472b48e 100755 (executable)
@@ -19,7 +19,7 @@ public final class ServletModuleDispatch {
   static Logfile theLog;
 
   static {
-    theLog = Logfile.getInstance("ServletModuleDispatch");
+    theLog = Logfile.getInstance("/tmp/smod.dispatch");
   }
 
   /**
@@ -43,7 +43,7 @@ public final class ServletModuleDispatch {
    */
 
   public static void dispatch(ServletModule sMod, HttpServletRequest req,
-    HttpServletResponse res) throws ServletModuleException
+    HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
   {
       //sMod.predeliver(req,res);
 
@@ -66,9 +66,16 @@ public final class ServletModuleDispatch {
       }
       catch ( NoSuchMethodException e) { throw new ServletModuleException("no such method!" + e.toString());}
       catch ( SecurityException e) { throw new ServletModuleException("method not allowed!" + e.toString());}
-      catch ( InvocationTargetException e) {e.printStackTrace();throw new ServletModuleException("target method exception!" + e.getTargetException().toString());}
+      catch ( InvocationTargetException e) {
+        if (e.getTargetException().getClass().getName() == "mir.servlet.ServletModuleUserException") {
+            throw new ServletModuleUserException(((ServletModuleUserException)e.getTargetException()).getMsg());
+        } else {
+            e.printStackTrace();
+            throw new ServletModuleException(e.getTargetException().toString());
+        }
+      }
       catch ( IllegalAccessException e) { throw new ServletModuleException("illegal method not allowed!" + e.toString());}
-//      catch ( Exception e ) { throw new ServletModuleException(e.toString()); }
+      //catch ( ServletModuleException e ) { throw new ServletModuleException(e.toString()); }
 
       throw new ServletModuleException("delivery failed! -- ");
   }