Skip to content

Commit

Permalink
Merge pull request #2 from soundcloud/master
Browse files Browse the repository at this point in the history
Remove warning about *root-dir* not being dynamic
  • Loading branch information
zk committed Mar 27, 2013
2 parents 0795193 + fc0d7aa commit 57c0fba
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 35 deletions.
70 changes: 42 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,82 @@ A Clojure client for [Exceptional](http://getexceptional.com).
## Usage

### Lein / Cake

[clj-exceptional "0.7.1"]

```clojure
[clj-exceptional "0.7.1"]
```

### Importing

(ns foo
(:require [clj-exceptional :as cx]))
```clojure
(ns foo
(:require [clj-exceptional :as cx]))

;; or
;; or

(ns foo
(:use cljs-exceptional))
(ns foo
(:use cljs-exceptional))
```

For the examples below I'll assume you're using the require method above.

### Basic Usage

Set your key !! IMPORTANT !!:

(cx/key! "exceptional_app_api_key")
```clojure
(cx/key! "exceptional_app_api_key")
```

Post an exception (blocking):

(cx/post-exc (Exception. "something went wrong!"))
```clojure
(cx/post-exc (Exception. "something went wrong!"))
```

Post an exception (non-blocking using agents):

(cx/post-exc-async (Exception. "something went wrong!"))

```clojure
(cx/post-exc-async (Exception. "something went wrong!"))
```



### "Catch" Macros

Wrap some code (`catch-exc` returns the caught exception):

(cx/catch-exc
(op-throw-exception))
```clojure
(cx/catch-exc
(op-throw-exception))

;; => #<Exception>
;; => #<Exception>
```

Wrap some code (`rethrow-exc` re-throws the caught exception):

(try
(cx/rethrow-exc
(op-throws-exception))
(catch Exception e (println "Something went wrong!!!)))

;; => nil


```clojure
(try
(cx/rethrow-exc
(op-throws-exception))
(catch Exception e (println "Something went wrong!!!")))

;; => nil
```
### Ring Handler

clj-exceptional contains ring handlers (`wrap-exceptional-catch` and
`wrap-exceptional-rethrow`) that will add information from
the request map to the post.

(def ring-app
(-> routes
(wrap-params)
(wrap-file "resources/public")
(wrap-file-info)
(cx/wrap-exceptional-catch))
```clojure
(def ring-app
(-> routes
(wrap-params)
(wrap-file "resources/public")
(wrap-file-info)
(cx/wrap-exceptional-catch))
```

This will send an exceptional post containing request parameters such
as `:remote-addr`, `:uri`, and `:headers`.
Expand Down
9 changes: 4 additions & 5 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(defproject clj-exceptional "0.7.1"
(defproject org.clojars.soundcloud/clj-exceptional "0.7.2"
:description "Clojure client for Exceptional http://getexceptional.com"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[cheshire "1.1.0"]
[clj-http "0.1.3"]]
:dependencies [[org.clojure/clojure "1.4.0"]
[cheshire "5.0.1"]
[clj-http "0.6.4"]]
:dev-dependencies [[swank-clojure "1.2.0"]
[lein-clojars "0.6.0"]])
4 changes: 2 additions & 2 deletions src/clj_exceptional.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(:import [java.text SimpleDateFormat])
(:refer-clojure :exclude [try]))

(def *root-dir* (.getAbsolutePath (java.io.File. "")))
(def absolute-root-dir (.getAbsolutePath (java.io.File. "")))
(def date-format "yyyy-MM-dd'T'HH:mm:ssZZZZ")
(def date-formatter (SimpleDateFormat. date-format))
(def _api-key (atom ""))
Expand Down Expand Up @@ -107,7 +107,7 @@
(message (.getMessage e))
(occured (now-iso)))
(appenv
(root-dir *root-dir*)
(root-dir absolute-root-dir)
(env java-env)
(language @_language)
(language-version @_language-version))
Expand Down

0 comments on commit 57c0fba

Please sign in to comment.