From 272bb16b2d434090008d0759e10ff28bab96cb51 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 28 Oct 2014 07:40:36 +0100 Subject: catch rendering exceptions --- controller/guicontroller.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'controller/guicontroller.php') 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 = '
' + . '

There was an error converting the note to HTML:

' + . '
' . htmlspecialchars($e->getMessage()) . '
' + . '

Please open a bug report at' + . ' ' + . 'github.com/cweiske/grauphel/issues' + . ' and attach the XML version of the note.' + . '

'; + } + $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( -- cgit v1.2.3