Browse files

Added better error message for missing handler

  • Loading branch information...
1 parent ce9e052 commit 525ccecdb60a32200b0b854d71a9cf40c2586873 @weavejester committed Aug 22, 2012
Showing with 19 additions and 2 deletions.
  1. +3 −1 src/leiningen/ring/server.clj
  2. +2 −0 src/leiningen/ring/uberwar.clj
  3. +11 −0 src/leiningen/ring/util.clj
  4. +3 −1 src/leiningen/ring/war.clj
View
4 src/leiningen/ring/server.clj
@@ -1,5 +1,6 @@
(ns leiningen.ring.server
- (:use [leinjacker.eval :only (eval-in-project)]))
+ (:use [leinjacker.eval :only (eval-in-project)]
+ leiningen.ring.util))
(defn load-namespaces
"Create require forms for each of the supplied symbols. This exists because
@@ -14,6 +15,7 @@
(defn server-task
"Shared logic for server and server-headless tasks."
[project options]
+ (ensure-handler-set! project)
(let [project (update-in project [:ring] merge options)]
(eval-in-project
(update-in project [:dependencies] conj ['ring-server "0.2.4"])
View
2 src/leiningen/ring/uberwar.clj
@@ -1,4 +1,5 @@
(ns leiningen.ring.uberwar
+ (:use leiningen.ring.util)
(:require [leiningen.ring.war :as war]
[leiningen.compile :as compile]
[clojure.java.io :as io]))
@@ -44,6 +45,7 @@
([project]
(uberwar project (default-uberwar-name project)))
([project war-name]
+ (ensure-handler-set! project)
(let [project (war/add-servlet-dep project)
result (compile/compile project)]
(when-not (and (number? result) (pos? result))
View
11 src/leiningen/ring/util.clj
@@ -0,0 +1,11 @@
+(ns leiningen.ring.util)
+
+(defn ensure-handler-set!
+ "Ensure the :handler option is set in the project map."
+ [project]
+ (when-not (-> project :ring :handler)
+ (println
+ (str "Missing Ring :handler option in project map.\n\n"
+ "You need to have a line in your project.clj file that looks like:\n"
+ " :ring {:handler your.app/handler}"))
+ (System/exit 1)))
View
4 src/leiningen/ring/war.clj
@@ -4,7 +4,8 @@
[clojure.java.io :as io]
[clojure.string :as string])
(:use [leinjacker.eval :only (eval-in-project)]
- [clojure.data.xml :only [sexp-as-element indent-str]])
+ [clojure.data.xml :only [sexp-as-element indent-str]]
+ leiningen.ring.util)
(:import [java.util.jar Manifest
JarEntry
JarOutputStream]
@@ -229,6 +230,7 @@
([project]
(war project (default-war-name project)))
([project war-name]
+ (ensure-handler-set! project)
(let [project (add-servlet-dep project)
result (compile/compile project)]
(when-not (and (number? result) (pos? result))

0 comments on commit 525ccec

Please sign in to comment.