File tree 5 files changed +66
-0
lines changed
bugsnag-spring/src/test/java/com/bugsnag
5 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,20 @@ public void springVersionSetCorrectly() {
171
171
assertEquals (SpringBootVersion .getVersion (), runtimeVersions .get ("springBoot" ));
172
172
}
173
173
174
+ @ Test
175
+ public void noBugsnagNotifyOnResponseStatusException () {
176
+ callResponseStatusExceptionEndpoint ();
177
+
178
+ verifyNoReport ();
179
+ }
180
+
181
+ @ Test
182
+ public void noBugsnagNotifyOnExceptionHandledByExceptionHandlerException () {
183
+ callResponseStatusExceptionEndpoint ();
184
+
185
+ verifyNoReport ();
186
+ }
187
+
174
188
@ Test
175
189
public void unhandledTypeMismatchExceptionSeverityInfo () {
176
190
callUnhandledTypeMismatchExceptionEndpoint ();
@@ -242,6 +256,16 @@ private void callUnhandledTypeMismatchExceptionEndpoint() {
242
256
"/throw-type-mismatch-exception" , String .class );
243
257
}
244
258
259
+ private void callResponseStatusExceptionEndpoint () {
260
+ this .restTemplate .getForEntity (
261
+ "/throw-response-status-exception" , String .class );
262
+ }
263
+
264
+ private void callCustomExceptionEndpoint () {
265
+ this .restTemplate .getForEntity (
266
+ "/throw-custom-exception" , String .class );
267
+ }
268
+
245
269
private void callHandledTypeMismatchExceptionUserSeverityEndpoint () {
246
270
this .restTemplate .getForEntity (
247
271
"/handled-type-mismatch-exception-user-severity" , String .class );
Original file line number Diff line number Diff line change @@ -33,6 +33,22 @@ public void throwTypeMismatchException() {
33
33
throw new TypeMismatchException ("Test" , String .class );
34
34
}
35
35
36
+ /**
37
+ * Throw an exception with @ResponseStatus
38
+ */
39
+ @ RequestMapping ("/throw-response-status-exception" )
40
+ public void throwResponseStatusException () {
41
+ throw new TestResponseStatusException ();
42
+ }
43
+
44
+ /**
45
+ * Throw an exception that is handled by @ExceptionHandler
46
+ */
47
+ @ RequestMapping ("/throw-custom-exception" )
48
+ public void throwCustomException () {
49
+ throw new TestCustomException ();
50
+ }
51
+
36
52
/**
37
53
* Report a handled exception where the severity reason is exceptionClass
38
54
*/
Original file line number Diff line number Diff line change
1
+ package com .bugsnag .testapp .springboot ;
2
+
3
+ public class TestCustomException extends RuntimeException {
4
+ }
Original file line number Diff line number Diff line change
1
+ package com .bugsnag .testapp .springboot ;
2
+
3
+ import org .springframework .http .ResponseEntity ;
4
+ import org .springframework .web .bind .annotation .ControllerAdvice ;
5
+ import org .springframework .web .bind .annotation .ExceptionHandler ;
6
+
7
+ @ ControllerAdvice
8
+ public class TestExceptionHandler {
9
+ @ ExceptionHandler (TestCustomException .class )
10
+ public ResponseEntity handleTestCustomException (TestCustomException ignored ) {
11
+ return ResponseEntity .ok (TestCustomException .class .getSimpleName ());
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ package com .bugsnag .testapp .springboot ;
2
+
3
+ import static org .springframework .http .HttpStatus .I_AM_A_TEAPOT ;
4
+
5
+ import org .springframework .web .bind .annotation .ResponseStatus ;
6
+
7
+ @ ResponseStatus (I_AM_A_TEAPOT )
8
+ public class TestResponseStatusException extends RuntimeException {
9
+ }
You can’t perform that action at this time.
0 commit comments