Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status is always nil on castra exceptions. #23

Open
jumblerg opened this issue Dec 20, 2016 · 1 comment
Open

status is always nil on castra exceptions. #23

jumblerg opened this issue Dec 20, 2016 · 1 comment
Assignees

Comments

@jumblerg
Copy link
Member

jumblerg commented Dec 20, 2016

when ex-data is called on the the error at line 26, it returns only {:castra.core/exception true} from the first exception in :via instead of the :data we're really interested in.

https://github.com/hoplon/castra/blob/master/src/castra/middleware.clj#L26

#error {
 :cause "clj-http: status 401"
 :data {:status 401, :headers {"Access-Control-Expose-Headers" "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Server" "GitHub.com", "Content-Type" "application/json; charset=utf-8", "Access-Control-Allow-Origin" "*", "X-Content-Type-Options" "nosniff", "Content-Length" "83", "X-Frame-Options" "deny", "Strict-Transport-Security" "max-age=31536000; includeSubdomains; preload", "X-RateLimit-Limit" "60", "X-RateLimit-Remaining" "54", "X-RateLimit-Reset" "1482225574", "Connection" "close", "Status" "401 Unauthorized", "X-GitHub-Request-Id" "CC09DC32:2ADB3:628F031:5858ED05", "X-GitHub-Media-Type" "github.v3; format=json", "Date" "Tue, 20 Dec 2016 08:34:13 GMT", "X-XSS-Protection" "1; mode=block", "Content-Security-Policy" "default-src 'none'"}, :body "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}", :request-time 852, :trace-redirects ["https://api.github.com/user"], :orig-content-encoding nil}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "Server error."
   :data {:castra.core/exception true}
   :at [clojure.core$ex_info invokeStatic "core.clj" 4617]}
  {:type clojure.lang.ExceptionInfo
   :message "clj-http: status 401"
   :data {:status 401, :headers {"Access-Control-Expose-Headers" "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Server" "GitHub.com", "Content-Type" "application/json; charset=utf-8", "Access-Control-Allow-Origin" "*", "X-Content-Type-Options" "nosniff", "Content-Length" "83", "X-Frame-Options" "deny", "Strict-Transport-Security" "max-age=31536000; includeSubdomains; preload", "X-RateLimit-Limit" "60", "X-RateLimit-Remaining" "54", "X-RateLimit-Reset" "1482225574", "Connection" "close", "Status" "401 Unauthorized", "X-GitHub-Request-Id" "CC09DC32:2ADB3:628F031:5858ED05", "X-GitHub-Media-Type" "github.v3; format=json", "Date" "Tue, 20 Dec 2016 08:34:13 GMT", "X-XSS-Protection" "1; mode=block", "Content-Security-Policy" "default-src 'none'"}, :body "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}", :request-time 852, :trace-redirects ["https://api.github.com/user"], :orig-content-encoding nil}
   :at [slingshot.support$stack_trace invoke "support.clj" 201]}]
 :trace
 [[slingshot.support$stack_trace invoke "support.clj" 201]
  [clj_http.client$wrap_exceptions$fn__4098 invoke "client.clj" 196]
  [clj_http.client$wrap_accept$fn__4302 invoke "client.clj" 565]
  [clj_http.client$wrap_accept_encoding$fn__4308 invoke "client.clj" 579]
  [clj_http.client$wrap_content_type$fn__4297 invoke "client.clj" 555]
  [clj_http.client$wrap_form_params$fn__4389 invoke "client.clj" 726]
  [clj_http.client$wrap_nested_params$fn__4406 invoke "client.clj" 751]
  [clj_http.client$wrap_method$fn__4349 invoke "client.clj" 670]
  [clj_http.cookies$wrap_cookies$fn__1847 invoke "cookies.clj" 124]
  [clj_http.links$wrap_links$fn__3095 invoke "links.clj" 51]
  [clj_http.client$wrap_unknown_host$fn__4415 invoke "client.clj" 771]
  [clj_http.client$get invokeStatic "client.clj" 874]
  [clj_http.client$get doInvoke "client.clj" 870]
  [clojure.lang.RestFn invoke "RestFn.java" 423]
  [panoply.backend.github$get_user invokeStatic "github.clj" 19]
  [panoply.backend.github$get_user invoke "github.clj" 17]
  [panoply.backend.api$get_user invokeStatic "api.clj" 11]
  [panoply.backend.api$get_user invoke "api.clj" 9]
  [clojure.lang.Var invoke "Var.java" 375]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.Var applyTo "Var.java" 700]
  [clojure.core$apply invokeStatic "core.clj" 646]
  [clojure.core$apply invoke "core.clj" 641]
  [castra.middleware$do_rpc invokeStatic "middleware.clj" 45]
  [castra.middleware$do_rpc invoke "middleware.clj" 41]
  [castra.middleware$wrap_castra$fn__1488$f__1489 invoke "middleware.clj" 127]
  [castra.middleware$wrap_castra$fn__1488$fn__1491 invoke "middleware.clj" 128]
  [castra.middleware$wrap_castra$fn__1488 invoke "middleware.clj" 128]
  [panoply.backend.github$wrap_token$fn__4526 invoke "github.clj" 29]
  [castra.middleware$wrap_castra_session$fn__1465 invoke "middleware.clj" 102]
  [clojure.lang.Var invoke "Var.java" 379]
  [ring.middleware.reload$wrap_reload$fn__7008 invoke "reload.clj" 38]
  [clojure.lang.Var invoke "Var.java" 379]
  [tailrecursion.clojure_adapter_servlet.impl$service invokeStatic "impl.clj" 137]
  [tailrecursion.clojure_adapter_servlet.impl$service invoke "impl.clj" 135]
  [clojure.lang.Var invoke "Var.java" 383]
  [tailrecursion.ClojureAdapterServlet service "ClojureAdapterServlet.java" 40]
  [org.eclipse.jetty.servlet.ServletHolder handle "ServletHolder.java" 816]
  [org.eclipse.jetty.servlet.ServletHandler doHandle "ServletHandler.java" 583]
  [org.eclipse.jetty.server.handler.ScopedHandler handle "ScopedHandler.java" 143]
  [org.eclipse.jetty.security.SecurityHandler handle "SecurityHandler.java" 548]
  [org.eclipse.jetty.server.session.SessionHandler doHandle "SessionHandler.java" 226]
  [org.eclipse.jetty.server.handler.ContextHandler doHandle "ContextHandler.java" 1113]
  [org.eclipse.jetty.servlet.ServletHandler doScope "ServletHandler.java" 511]
  [org.eclipse.jetty.server.session.SessionHandler doScope "SessionHandler.java" 185]
  [org.eclipse.jetty.server.handler.ContextHandler doScope "ContextHandler.java" 1047]
  [org.eclipse.jetty.server.handler.ScopedHandler handle "ScopedHandler.java" 141]
  [org.eclipse.jetty.server.handler.HandlerWrapper handle "HandlerWrapper.java" 119]
  [org.eclipse.jetty.server.Server handle "Server.java" 517]
  [org.eclipse.jetty.server.HttpChannel handle "HttpChannel.java" 302]
  [org.eclipse.jetty.server.HttpConnection onFillable "HttpConnection.java" 242]
  [org.eclipse.jetty.io.AbstractConnection$ReadCallback succeeded "AbstractConnection.java" 238]
  [org.eclipse.jetty.io.FillInterest fillable "FillInterest.java" 95]
  [org.eclipse.jetty.io.SelectChannelEndPoint$2 run "SelectChannelEndPoint.java" 57]
  [org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume produceAndRun "ExecuteProduceConsume.java" 213]
  [org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume run "ExecuteProduceConsume.java" 147]
  [org.eclipse.jetty.util.thread.QueuedThreadPool runJob "QueuedThreadPool.java" 654]
  [org.eclipse.jetty.util.thread.QueuedThreadPool$3 run "QueuedThreadPool.java" 572]
  [java.lang.Thread run "Thread.java" 745]]}
@jumblerg
Copy link
Member Author

this becomes problematic when, for example, we want to revert to a login or authentication view whenever the server returns a 404.

(defn initiate! [[view]]
  (-> (get-user)
      (.done #(change-state! :application))
      (.fail #(when (= (.-status %) 404) (change-state! :authentication)))))

@jumblerg jumblerg added the bug label Dec 20, 2016
jumblerg added a commit to jumblerg/castra that referenced this issue Dec 20, 2016
@ghost ghost assigned jumblerg Dec 20, 2016
@ghost ghost added the in progress label Dec 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant