From 686ffafa2123ad608120c6304c79fc3e04535b8d Mon Sep 17 00:00:00 2001 From: jungejason Date: Thu, 26 May 2011 14:17:12 -0700 Subject: [PATCH] Improve logging for syntax highlighting parsing Summary: add logging when syntax highlighting parsing throws exception. Test Plan: test when exception is thrown with non-php code. I couldn't create a file to trigger an exception in running pygmentiza, so I manually threw an exception to test it. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, epriestley CC: aran, tuomaspelkonen, jungejason Differential Revision: 350 --- .../changeset/DifferentialChangesetParser.php | 27 +++++++++++-------- .../parser/changeset/__init__.php | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index c4be7b3105..59aee6651f 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -464,17 +464,22 @@ class DifferentialChangesetParser { 'new' => $new_future, ); foreach (Futures($futures) as $key => $future) { - switch ($key) { - case 'old': - $this->oldRender = $this->processHighlightedSource( - $this->old, - $future->resolve()); - break; - case 'new': - $this->newRender = $this->processHighlightedSource( - $this->new, - $future->resolve()); - break; + try { + switch ($key) { + case 'old': + $this->oldRender = $this->processHighlightedSource( + $this->old, + $future->resolve()); + break; + case 'new': + $this->newRender = $this->processHighlightedSource( + $this->new, + $future->resolve()); + break; + } + } catch (Exception $ex) { + phlog($ex); + throw $ex; } } diff --git a/src/applications/differential/parser/changeset/__init__.php b/src/applications/differential/parser/changeset/__init__.php index e6fd9e2ec8..34285ac975 100644 --- a/src/applications/differential/parser/changeset/__init__.php +++ b/src/applications/differential/parser/changeset/__init__.php @@ -18,6 +18,7 @@ phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'storage/queryfx'); +phutil_require_module('phutil', 'error'); phutil_require_module('phutil', 'filesystem'); phutil_require_module('phutil', 'filesystem/tempfile'); phutil_require_module('phutil', 'future');