Skip to content

Commit

Permalink
error out for something things
Browse files Browse the repository at this point in the history
  • Loading branch information
hiredman committed Jun 19, 2013
1 parent 83dc034 commit 45bdb2b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
44 changes: 24 additions & 20 deletions clojurebot-eval/src/clojurebot/eval.clj
Expand Up @@ -5,26 +5,30 @@
[clojure.stacktrace :as s]))

(defn handler* [{{:strs [expression befuddled]} :params :as m}]
(try
(let [r (sb/eval-message expression (read-string befuddled))
[stdout stderr result] (if (vector? r)
r
[nil r nil])]
{:status 200
:body (pr-str {:stdout stdout
:stderr stderr
:result result})})
(catch Throwable t
(log/error t "error evaluating" expression)
(log/error (pr-str m))
{:status 200
:body (pr-str {:stdout ""
:stderr (pr-str
(try
(s/root-cause t)
(catch Throwable _
t)))
:result ""})})))
(if-not (and (.contains expression "shadow")
(.contains expression "worship"))
(try
(let [r (sb/eval-message expression (read-string befuddled))
[stdout stderr result] (if (vector? r)
r
[nil r nil])]
{:status 200
:body (pr-str {:stdout stdout
:stderr stderr
:result result})})
(catch Throwable t
(log/error t "error evaluating" expression)
(log/error (pr-str m))
{:status 200
:body (pr-str {:stdout ""
:stderr (print-str
(try
(s/root-cause t)
(catch Throwable _
t)))
:result ""})}))
{:status 500
:body ""}))

(def handler (-> #'handler*
wrap-params))
Expand Down
2 changes: 1 addition & 1 deletion clojurebot-eval/src/clojurebot/sandbox.clj
Expand Up @@ -327,7 +327,7 @@
(run [_]
(try
(evil cl "(+ 1 2)")
(catch java.lang.NoClassDefFoundError e
(catch Exception e
(swap! cl-cache dissoc clojure-jar)
(throw e))))))))
((fn [cl]
Expand Down

0 comments on commit 45bdb2b

Please sign in to comment.