diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2014-10-28 07:40:36 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2014-10-28 07:40:36 +0100 |
| commit | 272bb16b2d434090008d0759e10ff28bab96cb51 (patch) | |
| tree | 2bf6a867714bc0d8888d30f5053281a21f646c0b /controller/guicontroller.php | |
| parent | 0c9b45d210a5d94b3ba219e32b73233a5a795f61 (diff) | |
| download | grauphel-272bb16b2d434090008d0759e10ff28bab96cb51.tar.gz grauphel-272bb16b2d434090008d0759e10ff28bab96cb51.zip | |
catch rendering exceptions
Diffstat (limited to 'controller/guicontroller.php')
| -rw-r--r-- | controller/guicontroller.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/controller/guicontroller.php b/controller/guicontroller.php index fc97b04..534f18f 100644 --- a/controller/guicontroller.php +++ b/controller/guicontroller.php @@ -88,14 +88,26 @@ class GuiController extends Controller return new ErrorResponse('Note does not exist'); } - $converter = new \OCA\Grauphel\Lib\Converter\Html(); + $converter = new \OCA\Grauphel\Converter\Html(); $converter->internalLinkHandler = array($this, 'noteLinkHandler'); + + try { + $contentHtml = $converter->convert($note->{'note-content'}); + } catch (\OCA\Grauphel\Converter\Exception $e) { + $contentHtml = '<div class="error">' + . '<p>There was an error converting the note to HTML:</p>' + . '<blockquote><tt>' . htmlspecialchars($e->getMessage()) . '</tt></blockquote>' + . '<p>Please open a bug report at' + . ' <a class="lined" href="http://github.com/cweiske/grauphel/issues">' + . 'github.com/cweiske/grauphel/issues</a>' + . ' and attach the XML version of the note.' + . '</div>'; + } + $res->setParams( array( 'note' => $note, - 'note-content' => $converter->convert( - $note->{'note-content'} - ), + 'note-content' => $contentHtml, 'links' => array( 'json' => $this->urlGen->linkToRoute( 'grauphel.api.note', array( |
