X-Git-Url: https://git.cweiske.de/grauphel.git/blobdiff_plain/46a9ff9889466f23c310e2de100d0ae16c5a2a1a..81554f1309cc6a80578100b9583a591012df0d43:/controller/guicontroller.php diff --git a/controller/guicontroller.php b/controller/guicontroller.php index 4f74ab5..15380c7 100644 --- a/controller/guicontroller.php +++ b/controller/guicontroller.php @@ -59,7 +59,18 @@ class GuiController extends Controller */ public function index() { - $this->checkDeps(); + try { + $this->checkDeps(); + } catch (\Exception $e) { + $res = new TemplateResponse('grauphel', 'error'); + $res->setParams( + array( + 'message' => $e->getMessage(), + 'code' => $e->getCode(), + ) + ); + return $res; + } $res = new TemplateResponse('grauphel', 'index'); $res->setParams( @@ -85,21 +96,48 @@ class GuiController extends Controller $note = $this->getNotes()->load($guid, false); if ($note === null) { - return new ErrorResponse('Note does not exist'); + $res = new ErrorResponse('Note does not exist'); + $res->setStatus(\OCP\AppFramework\Http::STATUS_NOT_FOUND); + return $res; } - $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.' + . '