2i_utg
Last Updated: February 25, 2016
·
1.367K
· runexec
81609937c20aeab3598aea56f1f4f022

Clojure - Shortening long errors

Clojure - Shortening long errors

You don't always need the full message.

(str "Couldn't create db "
     @*db-name* "\r\n"
     (let
     [m (.getMessage e)]
       (if-not (> (count m)
              500)
           m
           (str (.subSequence m 0 100)
            "\r\n### keep-it-short ###\r\n"
            (.substring m
                (- (count m)
                   100))))))

uu.database=> (create-db)
Oct 02, 2012 11:02:03 AM sun.reflect.NativeMethodAccessorImpl invoke0
SEVERE: Alarm:> Failed create-db :> #{"Couldn't create db my-service\r\nthrow+: {:trace-redirects [\"http://localhost:5984/my-service\"], :request-time 30, :request {:\r\n### keep-it-short ###\r\nor\\\":\\\"file_exists\\\",\\\"reason\\\":\\\"The database could not be created, the file already exists.\\\"}\\n\"}"}

false
uu.database=> 
Say Thanks
Respond