Skip to content

Commit

Permalink
[#252] Modify stacktrace anomaly for instance not found
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed Jan 2, 2023
1 parent 223306d commit 9979163
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/src/clojure/org/akvo/flow_api/anomaly.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(map? m)]}
(throw (ex-info message (assoc m :org.akvo.flow-api/anomaly key))))

(defn not-found [message m]
(defn not-found [^String message m]
(throw-anomaly ::not-found message m))

(defn unauthorized [message m]
Expand Down
7 changes: 4 additions & 3 deletions api/src/clojure/org/akvo/flow_api/middleware/anomaly.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require [org.akvo.flow-api.endpoint.anomaly :as anomaly]
[org.akvo.flow-api.anomaly :as an]
#_[clojure.tools.logging :as log]
[clojure.stacktrace :as stacktrace])
#_[clojure.stacktrace :as stacktrace])
(:import [clojure.lang ExceptionInfo]))

(defn wrap-anomaly [handler]
Expand All @@ -17,13 +17,14 @@
"Over Quota" (an/too-many-requests)
"required more quota" (an/too-many-requests)
"Please try again in 30 seconds" (an/bad-gateway)
(throw e)))
((println (str "The message" e))
(throw e))))

(defn wrap-log-errors [handler]
(fn [request]
(try
(handler request)
(catch Throwable e
(stacktrace/print-stack-trace e)
#_(stacktrace/print-stack-trace e)
#_(log/error e (str "Error:" (.getMessage e)))
(translate-exception e)))))
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
(handler (assoc request
:instance-id instance-id
:alias alias)))
(anomaly/not-found "Could not resolve alias"
{:alias alias}))))
(anomaly/not-found (str alias " instance not found.") {}))))

0 comments on commit 9979163

Please sign in to comment.