mirror of
https://github.com/alopexc0de/Simple-Bookmarking-Service.git
synced 2024-12-22 06:22:39 +00:00
Raise 404 when bookmark(s) doesn't exist
This commit is contained in:
parent
b5a67b1216
commit
74161608df
@ -10,7 +10,7 @@ import json
|
|||||||
import datetime
|
import datetime
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
from bottle import response
|
from bottle import response, abort
|
||||||
from .db import Database
|
from .db import Database
|
||||||
|
|
||||||
class API:
|
class API:
|
||||||
@ -56,6 +56,9 @@ class API:
|
|||||||
response.content_type = self.response_type
|
response.content_type = self.response_type
|
||||||
bookmark = self.database.get_bookmark(UUID(bookmark_id))
|
bookmark = self.database.get_bookmark(UUID(bookmark_id))
|
||||||
|
|
||||||
|
if bookmark == None:
|
||||||
|
return abort(404, "Provided bookmark doesn't exist or has been deleted")
|
||||||
|
|
||||||
# Maybe I need to use `sqlite3.Cursor.description` or `sqlite3.Row.keys()`
|
# Maybe I need to use `sqlite3.Cursor.description` or `sqlite3.Row.keys()`
|
||||||
bookmark_object = {
|
bookmark_object = {
|
||||||
'uuid': bookmark[0].hex,
|
'uuid': bookmark[0].hex,
|
||||||
@ -77,6 +80,9 @@ class API:
|
|||||||
response.content_type = self.response_type
|
response.content_type = self.response_type
|
||||||
bookmarks = self.database.get_all_bookmarks()
|
bookmarks = self.database.get_all_bookmarks()
|
||||||
|
|
||||||
|
if len(bookmarks) == 0:
|
||||||
|
return abort(404, "There are no bookmarks saved")
|
||||||
|
|
||||||
bookmark_object = [
|
bookmark_object = [
|
||||||
{
|
{
|
||||||
'uuid': bookmark[0].hex,
|
'uuid': bookmark[0].hex,
|
||||||
|
Loading…
Reference in New Issue
Block a user