From ea2de68b471d335f8970e0fdd06ac04579fabbdd Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Fri, 10 May 2019 14:01:24 +0200 Subject: [PATCH] Add simple error handling --- server/api/api.lisp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/server/api/api.lisp b/server/api/api.lisp index d41921e..af5fe13 100644 --- a/server/api/api.lisp +++ b/server/api/api.lisp @@ -56,12 +56,19 @@ (defmethod handle-request ((api api) request) - (let* ((data (parse-request request)) - (type (getf data :type))) - (cond - ((equal type "new-game") (handle-new-game api data)) - ((equal type "update") (handle-update api data)) - (t (format t "Unknow type"))))) + (flet ((handle-fun () + (let* ((data (parse-request request)) + (type (getf data :type))) + (cond + ((equal type "new-game") (handle-new-game api data)) + ((equal type "update") (handle-update api data)) + (t (format t "Unknow type")))))) + + (handler-case + (handle-fun) + (t (c) + (format t "Got an exception: ~a~%" c) + "Bad request"))))