Skip to content

Commit

Permalink
Better error message when query can't be parsed.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jan 9, 2013
1 parent 5bc95ba commit a739620
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/clojars/web/search.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@
(html-doc account (str (h query) " - search")
[:h1 "Search for " (h query)]
[:ul
(let [results (search/search query)]
(if (empty? results)
[:p "No results."]
(for [jar results
;; bc too lazy to see why blank entries are showing up
:when (not (nil? (:artifact-id jar)))]
[:li.search-results
(jar-link {:jar_name (:artifact-id jar)
:group_name (:group-id jar)}) " " (h (:version jar))
[:br]
(when (seq (:description jar))
[:span.desc (h (:description jar))
[:br]])
[:span.details (if-let [created (:created jar)]
[:td (format-date created)])]])))]))
(try
(let [results (search/search query)]
(if (empty? results)
[:p "No results."]
(for [jar results
;; bc too lazy to see why blank entries are showing up
:when (not (nil? (:artifact-id jar)))]
[:li.search-results
(jar-link {:jar_name (:artifact-id jar)
:group_name (:group-id jar)}) " " (h (:version jar))
[:br]
(when (seq (:description jar))
[:span.desc (h (:description jar))
[:br]])
[:span.details (if-let [created (:created jar)]
[:td (format-date created)])]])))
(catch Exception _
[:p "Could not search; please check your query syntax."]))]))

(defn search [account params]
(let [q (params :q)]
Expand Down

0 comments on commit a739620

Please sign in to comment.