@@ -36,6 +36,11 @@ def test_stacktraces_basics(self) -> None:
3636 assert len (infos ) == 1
3737 assert len (infos [0 ].stacktrace ["frames" ]) == 2
3838 assert infos [0 ].platforms == {"javascript" , "native" }
39+ # Top-level stacktraces are not exceptions
40+ assert infos [0 ].is_exception is False
41+ assert infos [0 ].exception_type is None
42+ assert infos [0 ].exception_module is None
43+ assert infos [0 ].get_exception () is None
3944
4045 def test_stacktraces_exception (self ) -> None :
4146 data : dict [str , Any ] = {
@@ -69,6 +74,42 @@ def test_stacktraces_exception(self) -> None:
6974 infos = find_stacktraces_in_data (data )
7075 assert len (infos ) == 1
7176 assert len (infos [0 ].stacktrace ["frames" ]) == 2
77+ # Exception stacktraces have type but no module in this case
78+ assert infos [0 ].is_exception is True
79+ assert infos [0 ].exception_type == "Error"
80+ assert infos [0 ].exception_module is None
81+ assert infos [0 ].get_exception () == "Error"
82+
83+ def test_stacktraces_exception_with_module (self ) -> None :
84+ data : dict [str , Any ] = {
85+ "message" : "hello" ,
86+ "platform" : "java" ,
87+ "exception" : {
88+ "values" : [
89+ {
90+ "type" : "RuntimeException" ,
91+ "module" : "java.lang" ,
92+ "stacktrace" : {
93+ "frames" : [
94+ {
95+ "function" : "main" ,
96+ "module" : "com.example.App" ,
97+ "filename" : "App.java" ,
98+ "lineno" : 10 ,
99+ },
100+ ]
101+ },
102+ }
103+ ]
104+ },
105+ }
106+
107+ infos = find_stacktraces_in_data (data )
108+ assert len (infos ) == 1
109+ assert infos [0 ].is_exception is True
110+ assert infos [0 ].exception_type == "RuntimeException"
111+ assert infos [0 ].exception_module == "java.lang"
112+ assert infos [0 ].get_exception () == "java.lang.RuntimeException"
72113
73114 def test_stacktraces_threads (self ) -> None :
74115 data : dict [str , Any ] = {
@@ -102,6 +143,11 @@ def test_stacktraces_threads(self) -> None:
102143 infos = find_stacktraces_in_data (data )
103144 assert len (infos ) == 1
104145 assert len (infos [0 ].stacktrace ["frames" ]) == 2
146+ # Thread stacktraces are not exceptions
147+ assert infos [0 ].is_exception is False
148+ assert infos [0 ].exception_type is None
149+ assert infos [0 ].exception_module is None
150+ assert infos [0 ].get_exception () is None
105151
106152 def test_find_stacktraces_skip_none (self ) -> None :
107153 # This tests:
@@ -147,13 +193,19 @@ def test_find_stacktraces_skip_none(self) -> None:
147193 assert len (infos ) == 4
148194 assert sum (1 for x in infos if x .stacktrace ) == 3
149195 assert sum (1 for x in infos if x .is_exception ) == 4
196+ # All exceptions have type "Error" and no module
197+ assert all (x .exception_type == "Error" for x in infos )
198+ assert all (x .exception_module is None for x in infos )
199+ assert all (x .get_exception () == "Error" for x in infos )
150200 # XXX: The null frame is still part of this stack trace!
151201 assert len (infos [3 ].stacktrace ["frames" ]) == 3
152202
153203 infos = find_stacktraces_in_data (data )
154204 assert len (infos ) == 1
155205 # XXX: The null frame is still part of this stack trace!
156206 assert len (infos [0 ].stacktrace ["frames" ]) == 3
207+ assert infos [0 ].exception_type == "Error"
208+ assert infos [0 ].get_exception () == "Error"
157209
158210
159211@pytest .mark .parametrize (
0 commit comments