Closed ccfontes closed 10 years ago
I don't think lib-noir would be the right place to add this feature. The exception handling is tied in with the Noir server code and checks whether the dev flag is set or not when rendering exceptions. Following that model it would make more sense to add this wrapper to Luminus instead.
Also, note that Ring already pretty prints exception stacktraces in dev mode.
By adding to Luminus, do you mean the project template? I can understand your worry to include it in lib-noir
, but excluding everyone who doesn't use Luminus doesn't sound that useful either.
How about a dedicated project like noir-stacktraces?
So, aside from CSS styling how would this be different from the Ring stacktrace exception wrapper?
That's totally cool! I didn't know about wrap-stacktrace-web
. Anyway, it seems there is more than a styling diference. The criterion for highlighting with the Noir style is: "does this namespace belong to this project?", whereas the ring one means something I cannot grasp yet. An excerpt of the same stack trace with the two different styles follows:
The screenshot with the Noir style was taken from my own in-house adaptation, though. Example: I couldn't make it know the current namespace dynamically, so I had to do it statically, But I think the criterion is still the same. It should be confirmed if the original criterion is really the same.
IMO, it's useful to have the project forms highlighted, but others may find other information more useful.
Noir kept track of project namespaces explicitly, but this wouldn't be simple to port to a standalone library. I agree that there would be value to that, but it's a bit of a question as to how to accomplish this in automated fashion.
I'm going to try it.
@ccfontes you could do something like the following to get a list of all the namespaces that belong to the project:
(ns classpath
(:require [clojure.string :as str]))
(defn project-path []
(-> (System/getProperties)
(.get "clojure.compile.path")
(.split "/target")
first))
(defn get-ns-name [file]
(with-open [rdr (java.io.PushbackReader. (clojure.java.io/reader file))]
(binding [*read-eval* false]
(second (read rdr)))))
(defn list-namespaces []
(->> (project-path)
clojure.java.io/file
file-seq
(filter #(.endsWith (.getName %) ".clj"))
(map get-ns-name)))
The above should extract all the names for the local namespaces in the project.
Nice! I was going to start working on that just now haha. Sorry for all the trouble.
No problem, let me know if it's working as expected and feel free to send a pr if you'd like to change anything.
Awesome! It works :D I'm closing this.
Wouldn't it be cool to include those pretty stack traces? They are so useful, specially to visualize lines that belong to the project namespaces.