File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 72
72
(str enum-symbol " /" )
73
73
symbol)])
74
74
enum-map)
75
- (throw (ex-info ~(format " Invalid Enum key - possible keys are -> %s"
76
- (str/join " , " (map key enum-map)))
77
- {:type ::invalid-enum-value
78
- :key x#})))))))
75
+ (throw (ex-info
76
+ (format " Invalid Enum key - %s - possible keys are -> %s"
77
+ x#
78
+ ~(str/join " , " (map key enum-map)))
79
+ {:type ::invalid-enum-value
80
+ :key x#})))))))
Original file line number Diff line number Diff line change 1
1
(ns qbits.commons.enum-test
2
2
(:require
3
3
[clojure.test :as t :refer [deftest testing is]]
4
- [qbits.commons.enum :as sut])
4
+ [qbits.commons.enum :as sut]
5
+ [clojure.string :as str])
5
6
(:import
6
7
[java.math RoundingMode]))
7
8
12
13
(is (instance? RoundingMode v))
13
14
(is (= " UP" (str v)))))
14
15
15
- (testing " invalid key is reported in ex-data"
16
+ (testing " invalid key is reported in ex-data and exception message "
16
17
(let [efn (sut/enum->fn RoundingMode)
17
18
v (try
18
19
(efn :foo )
19
20
(catch Exception err err))
20
21
{exd-t :type
21
22
exd-k :key
22
- :as exd} (ex-data v)]
23
+ :as exd} (ex-data v)
24
+ ex-msg (when (instance? Exception v) (.getMessage ^Exception v))]
23
25
(is (some? exd))
24
26
(is (= ::sut/invalid-enum-value exd-t))
25
- (is (= :foo exd-k)))))
27
+ (is (= :foo exd-k))
28
+ (is (str/starts-with? ex-msg " Invalid Enum key - :foo" )))))
You can’t perform that action at this time.
0 commit comments