Back

ex-triage (clj)

(source)

function

(ex-triage datafied-throwable)
Returns an analysis of the phase, error, cause, and location of an error that occurred based on Throwable data, as returned by Throwable->map. All attributes other than phase are optional: :clojure.error/phase - keyword phase indicator, one of: :read-source :compile-syntax-check :compilation :macro-syntax-check :macroexpansion :execution :read-eval-result :print-eval-result :clojure.error/source - file name (no path) :clojure.error/path - source path :clojure.error/line - integer line number :clojure.error/column - integer column number :clojure.error/symbol - symbol being expanded/compiled/invoked :clojure.error/class - cause exception class symbol :clojure.error/cause - cause exception message :clojure.error/spec - explain-data for spec error

Examples

clojure

(ns clojure.test-clojure.main
  (:use clojure.test
        [clojure.test-helper :only [platform-newlines]])
  (:require [clojure.main :as main]))

(deftest null-stack-error-reporting
  (let [e (doto (Error. "xyz")
            (.setStackTrace (into-array java.lang.StackTraceElement nil)))
        tr-data (-> e Throwable->map main/ex-triage)]
    (is (= tr-data #:clojure.error{:phase :execution, :class 'java.lang.Error, :cause "xyz"}))
    (is (= (main/ex-str tr-data) (platform-newlines "Execution error (Error) at (REPL:1).\nxyz\n")))))