Skip to content

Commit a615827

Browse files
committed
Add HTTP 500 handler for the API
1 parent c64a74d commit a615827

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ Expect that this API might change between now and any time this is released.
259259

260260
- API for adding examples
261261
- API for adding comments
262+
- Tests!
262263

263264
## See Also
264265

src/eisago/api.clj

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
[req]
1111
{:status 404 :body (json/encode {:status 404 :message "Invalid request"})})
1212

13+
(defn error
14+
"Response for API 500 errors"
15+
[req]
16+
{:status 500 :body (json/encode {:status 500
17+
:message "There was an unknown error"})})
18+
1319
(defn search
1420
"API implementation of searching, lib and namespace can be optionally
1521
specified as paths, with name and query optionally specified in
@@ -75,7 +81,8 @@
7581

7682
#"^/_stats/?$" #'stats
7783

78-
:404 #'missing))
84+
:404 #'missing
85+
:500 #'error))
7986

8087
(defn start-server []
8188
(laeggen/start (assoc (config :laeggen) :urls urls)))

0 commit comments

Comments
 (0)