File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 125
125
(catch TypeError _
126
126
(count (apply vector coll))))))
127
127
128
+ (def
129
+ ^{:doc "Returns a basilisp.lang.exception/ExceptionInfo instance with
130
+ the given message and data."}
131
+ ex-info
132
+ (fn ex-info [msg data]
133
+ (basilisp.lang.exception/ExceptionInfo msg data)))
134
+
128
135
(def
129
136
^{:macro true
130
- :doc ""}
137
+ :doc "Define a new function. "}
131
138
defn
132
139
(fn defn [&form name & body]
133
140
(let [body (concat body)
Original file line number Diff line number Diff line change
1
+ import basilisp .lang .map as lmap
2
+ from basilisp .lang .util import lrepr
3
+
4
+
5
+ class ExceptionInfo (Exception ):
6
+ __slots__ = ('_msg' , '_data' ,)
7
+
8
+ def __init__ (self , message : str , data : lmap .Map ) -> None :
9
+ super ().__init__ ()
10
+ self ._msg = message
11
+ self ._data = data
12
+
13
+ def __repr__ (self ):
14
+ return f"basilisp.lang.exception.ExceptionInfo({ self ._msg } , { lrepr (self ._data )} )"
15
+
16
+ def __str__ (self ):
17
+ return f"{ self ._msg } { lrepr (self ._data )} "
18
+
19
+ @property
20
+ def data (self ):
21
+ return self ._data
22
+
23
+ @property
24
+ def message (self ):
25
+ return self ._data
Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ class Namespace:
177
177
- `imports` is a set of Python modules imported into the current
178
178
namespace"""
179
179
DEFAULT_IMPORTS = atom .Atom (pset (seq (['builtins' ,
180
+ 'basilisp.lang.exception' ,
180
181
'basilisp.lang.keyword' ,
181
182
'basilisp.lang.list' ,
182
183
'basilisp.lang.map' ,
Original file line number Diff line number Diff line change 1
1
from unittest .mock import Mock
2
2
3
+ import pytest
4
+
5
+ import basilisp .lang .map as lmap
3
6
import basilisp .lang .runtime as runtime
7
+ from basilisp .lang .exception import ExceptionInfo
4
8
from basilisp .main import init
5
9
6
10
init ()
@@ -25,3 +29,8 @@ def teardown_module(module):
25
29
26
30
def test_first ():
27
31
assert None is basilisp .core .first (None )
32
+
33
+
34
+ def test_ex_info ():
35
+ with pytest .raises (ExceptionInfo ):
36
+ raise basilisp .core .ex_info ("This is just an exception" , lmap .m ())
You can’t perform that action at this time.
0 commit comments