Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.36
diff -u -p -r1.36 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	30 Aug 2008 09:42:25 -0000	1.36
+++ modules/simpletest/drupal_web_test_case.php	3 Sep 2008 17:50:35 -0000
@@ -275,13 +275,19 @@ class DrupalWebTestCase {
    */
   function run() {
     set_error_handler(array($this, 'errorHandler'));
+    set_exception_handler(array($this, 'exceptionHandler'));
     $methods = array();
     // Iterate through all the methods in this class.
     foreach (get_class_methods(get_class($this)) as $method) {
       // If the current method starts with "test", run it - it's a test.
       if (strtolower(substr($method, 0, 4)) == 'test') {
         $this->setUp();
-        $this->$method();
+        try {
+          $this->$method();
+        }
+        catch (Exception $e) {
+          $this->exceptionHandler($e);
+        }
         // Finish up.
         $this->tearDown();
       }
@@ -318,6 +324,19 @@ class DrupalWebTestCase {
   }
 
   /**
+   * Handle exceptions.
+   *
+   * @see set_exceptions_handler
+   */
+  function exceptionHandler($exception) {
+    $this->error($exception->getMessage(), 'Uncaught exception', array(
+      'function' => '',
+      'line' => $exception->getLine(),
+      'file' => $exception->getFile(),
+    ));
+  }
+
+  /**
    * Creates a node based on default settings.
    *
    * @param $settings
