Send 404 if a note cannot be found
authorChristian Weiske <cweiske@cweiske.de>
Tue, 17 Mar 2015 18:53:17 +0000 (19:53 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 17 Mar 2015 18:53:17 +0000 (19:53 +0100)
controller/guicontroller.php
controller/notescontroller.php

index b09ef4a..8ebea8c 100644 (file)
@@ -96,7 +96,9 @@ 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\Converter\Html();
index 02bfc93..5618bcb 100644 (file)
@@ -58,6 +58,11 @@ class NotesController extends Controller
     public function xml($guid)
     {
         $note = $this->getNotes()->load($guid, false);
+        if ($note === null) {
+            $res = new ErrorResponse('Note does not exist');
+            $res->setStatus(\OCP\AppFramework\Http::STATUS_NOT_FOUND);
+            return $res;
+        }
 
         $xw = new \XMLWriter();
         $xw->openMemory();