From 400268b0186b0d50c1418758575346ff15c4ab60 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:59:55 +0000 Subject: [PATCH] Better user errors --- server/routes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/routes.py b/server/routes.py index bab7594..1cf1830 100644 --- a/server/routes.py +++ b/server/routes.py @@ -16,12 +16,16 @@ def index(): "SELECT * FROM books WHERE name LIKE '%" + name + "%'" ) books = [Book(*row) for row in cursor] + if len(books) == 0: + return make_response(f"No search results for Name: {name}", 404) elif author: cursor.execute( "SELECT * FROM books WHERE author LIKE '%" + author + "%'" ) books = [Book(*row) for row in cursor] + if len(books) == 0: + return make_response(f"No search results for Author: {author}", 404) else: cursor.execute("SELECT name, author, read FROM books")