diff --git a/resources/sql/autopatches/20151108.xhpast.stderr.sql b/resources/sql/autopatches/20151108.xhpast.stderr.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20151108.xhpast.stderr.sql
@@ -0,0 +1,5 @@
+ALTER TABLE {$NAMESPACE}_xhpastview.xhpastview_parsetree
+  ADD returnCode INT NOT NULL AFTER input;
+
+ALTER TABLE {$NAMESPACE}_xhpastview.xhpastview_parsetree
+  ADD stderr longtext NOT NULL AFTER stdout;
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewController.php
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewController.php
@@ -3,7 +3,6 @@
 abstract class PhabricatorXHPASTViewController extends PhabricatorController {
 
   public function buildStandardPageResponse($view, array $data) {
-
     $page = $this->buildStandardPageView();
 
     $page->setApplicationName('XHPASTView');
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php
@@ -10,17 +10,17 @@
   public function handleRequest(AphrontRequest $request) {
     $id = $request->getURIData('id');
 
-    $response = new AphrontWebpageResponse();
-    $response->setFrameable(true);
-    $response->setContent(phutil_tag(
+    $content = phutil_tag(
       'frameset',
       array('cols' => '33%, 34%, 33%'),
-      array(
-        phutil_tag('frame', array('src' => "/xhpast/input/{$id}/")),
-        phutil_tag('frame', array('src' => "/xhpast/tree/{$id}/")),
-        phutil_tag('frame', array('src' => "/xhpast/stream/{$id}/")),
-      )));
+        array(
+          phutil_tag('frame', array('src' => "/xhpast/input/{$id}/")),
+          phutil_tag('frame', array('src' => "/xhpast/tree/{$id}/")),
+          phutil_tag('frame', array('src' => "/xhpast/stream/{$id}/")),
+      ));
 
-    return $response;
+    return id(new AphrontWebpageResponse())
+      ->setFrameable(true)
+      ->setContent($content);
   }
 }
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php
@@ -14,6 +14,7 @@
     $this->id = $data['id'];
     $this->storageTree = id(new PhabricatorXHPASTViewParseTree())
       ->load($this->id);
+
     if (!$this->storageTree) {
       throw new Exception(pht('No such AST!'));
     }
@@ -65,10 +66,9 @@
       '</html>',
       $content);
 
-    $response = new AphrontWebpageResponse();
-    $response->setFrameable(true);
-    $response->setContent($content);
-    return $response;
+    return id(new AphrontWebpageResponse())
+      ->setFrameable(true)
+      ->setContent($content);
   }
 
 }
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php
@@ -13,17 +13,21 @@
       $resolved = $future->resolve();
 
       // This is just to let it throw exceptions if stuff is broken.
-      $parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture(
-        $source,
-        $resolved);
+      try {
+        XHPASTTree::newFromDataAndResolvedExecFuture($source, $resolved);
+      } catch (XHPASTSyntaxErrorException $ex) {
+        // This is possibly expected.
+      }
 
       list($err, $stdout, $stderr) = $resolved;
 
-      $storage_tree = new PhabricatorXHPASTViewParseTree();
-      $storage_tree->setInput($source);
-      $storage_tree->setStdout($stdout);
-      $storage_tree->setAuthorPHID($viewer->getPHID());
-      $storage_tree->save();
+      $storage_tree = id(new PhabricatorXHPASTViewParseTree())
+        ->setInput($source)
+        ->setReturnCode($err)
+        ->setStdout($stdout)
+        ->setStderr($stderr)
+        ->setAuthorPHID($viewer->getPHID())
+        ->save();
 
       return id(new AphrontRedirectResponse())
         ->setURI('/xhpast/view/'.$storage_tree->getID().'/');
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php
@@ -6,11 +6,17 @@
   public function handleRequest(AphrontRequest $request) {
     $storage = $this->getStorageTree();
     $input = $storage->getInput();
+    $err = $storage->getReturnCode();
     $stdout = $storage->getStdout();
+    $stderr = $storage->getStderr();
+
+    if ($stderr) {
+      return $this->buildXHPASTViewPanelResponse($stderr);
+    }
 
     $tree = XHPASTTree::newFromDataAndResolvedExecFuture(
       $input,
-      array(0, $stdout, ''));
+      array($err, $stdout, $stderr));
 
     $tokens = array();
     foreach ($tree->getRawTokenStream() as $id => $token) {
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
@@ -10,18 +10,23 @@
   public function handleRequest(AphrontRequest $request) {
     $storage = $this->getStorageTree();
     $input = $storage->getInput();
+    $err = $storage->getReturnCode();
     $stdout = $storage->getStdout();
+    $stderr = $storage->getStderr();
+
+    if ($stderr) {
+      return $this->buildXHPASTViewPanelResponse($stderr);
+    }
 
     $tree = XHPASTTree::newFromDataAndResolvedExecFuture(
       $input,
-      array(0, $stdout, ''));
+      array($err, $stdout, $stderr));
 
     $tree = phutil_tag('ul', array(), $this->buildTree($tree->getRootNode()));
     return $this->buildXHPASTViewPanelResponse($tree);
   }
 
   protected function buildTree($root) {
-
     try {
       $name = $root->getTypeName();
       $title = $root->getDescription();
diff --git a/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php b/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php
--- a/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php
+++ b/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php
@@ -3,16 +3,19 @@
 final class PhabricatorXHPASTViewParseTree extends PhabricatorXHPASTViewDAO {
 
   protected $authorPHID;
-
   protected $input;
+  protected $returnCode;
   protected $stdout;
+  protected $stderr;
 
   protected function getConfiguration() {
     return array(
       self::CONFIG_COLUMN_SCHEMA => array(
         'authorPHID' => 'phid?',
         'input' => 'text',
+        'returnCode' => 'sint32',
         'stdout' => 'text',
+        'stderr' => 'text',
       ),
     ) + parent::getConfiguration();
   }