Skip to content

Commit b7e42d4

Browse files
committed
refactor(Event): rename Exception -> Error
1 parent c994bfa commit b7e42d4

7 files changed

Lines changed: 33 additions & 33 deletions

File tree

bugsnag/src/main/java/com/bugsnag/Exception.java renamed to bugsnag/src/main/java/com/bugsnag/Error.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import java.util.List;
66

7-
class Exception {
7+
public class Error {
88
private Configuration config;
99
private Throwable throwable;
1010
private String errorClass;
1111

12-
Exception(Configuration config, Throwable throwable) {
12+
Error(Configuration config, Throwable throwable) {
1313
this.config = config;
1414
this.throwable = throwable;
1515
this.errorClass = throwable.getClass().getName();

bugsnag/src/main/java/com/bugsnag/Event.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Event {
1818
private Configuration config;
1919

2020
private String apiKey;
21-
private final Exception exception;
21+
private final Error error;
2222
private HandledState handledState;
2323
private Severity severity;
2424
private String groupingHash;
@@ -47,7 +47,7 @@ protected Event(Configuration config, Throwable throwable) {
4747
Event(Configuration config, Throwable throwable,
4848
HandledState handledState, Thread currentThread, FeatureFlagStore clientFeatureFlagStore) {
4949
this.config = config;
50-
this.exception = new Exception(config, throwable);
50+
this.error = new Error(config, throwable);
5151
this.handledState = handledState;
5252
this.severity = handledState.getOriginalSeverity();
5353
diagnostics = new Diagnostics(this.config);
@@ -78,17 +78,17 @@ protected String getPayloadVersion() {
7878
* @return the exceptions that make up the error.
7979
*/
8080
@Expose
81-
protected List<Exception> getExceptions() {
82-
List<Exception> exceptions = new ArrayList<Exception>();
83-
exceptions.add(exception);
81+
protected List<Error> getErrors() {
82+
List<Error> errors = new ArrayList<Error>();
83+
errors.add(error);
8484

85-
Throwable currentThrowable = exception.getThrowable().getCause();
85+
Throwable currentThrowable = error.getThrowable().getCause();
8686
while (currentThrowable != null) {
87-
exceptions.add(new Exception(config, currentThrowable));
87+
errors.add(new Error(config, currentThrowable));
8888
currentThrowable = currentThrowable.getCause();
8989
}
9090

91-
return exceptions;
91+
return errors;
9292
}
9393

9494
@Expose
@@ -168,14 +168,14 @@ void setSession(Session session) {
168168
* report.
169169
*/
170170
public Throwable getException() {
171-
return exception.getThrowable();
171+
return error.getThrowable();
172172
}
173173

174174
/**
175175
* @return the class name from the exception contained in this error report.
176176
*/
177177
public String getExceptionName() {
178-
return exception.getErrorClass();
178+
return error.getErrorClass();
179179
}
180180

181181
/**
@@ -184,14 +184,14 @@ public String getExceptionName() {
184184
* @param exceptionName the error name
185185
*/
186186
public void setExceptionName(String exceptionName) {
187-
exception.setErrorClass(exceptionName);
187+
error.setErrorClass(exceptionName);
188188
}
189189

190190
/**
191191
* @return The message from the exception contained in this error report.
192192
*/
193193
public String getExceptionMessage() {
194-
return exception.getThrowable().getLocalizedMessage();
194+
return error.getThrowable().getLocalizedMessage();
195195
}
196196

197197
/**

bugsnag/src/main/java/com/bugsnag/Stackframe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.ArrayList;
66
import java.util.List;
77

8-
class Stackframe {
8+
public class Stackframe {
99
private Configuration config;
1010
private StackTraceElement el;
1111

bugsnag/src/test/java/com/bugsnag/AppenderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public void testProjectPackages() {
249249
Notification notification = delivery.getNotifications().get(0);
250250
Event event = notification.getEvents().get(0);
251251

252-
List<Stackframe> frames = event.getExceptions().get(0).getStacktrace();
252+
List<Stackframe> frames = event.getErrors().get(0).getStacktrace();
253253
assertTrue(frames.get(0).isInProject());
254254
assertTrue(frames.get(1).isInProject());
255255
for (int i = 2; i < frames.size(); i++) {

bugsnag/src/test/java/com/bugsnag/BugsnagTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void testProjectPackages() {
105105
@Override
106106
public void deliver(Serializer serializer, Object object, Map<String, String> headers) {
107107
Event event = ((Notification) object).getEvents().get(0);
108-
assertTrue(event.getExceptions().get(0).getStacktrace().get(0).isInProject());
108+
assertTrue(event.getErrors().get(0).getStacktrace().get(0).isInProject());
109109
}
110110

111111
@Override

bugsnag/src/test/java/com/bugsnag/ExceptionTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public class ExceptionTest {
1818

19-
private Exception exception;
19+
private Error error;
2020
private RuntimeException ogThrowable;
2121

2222
/**
@@ -28,22 +28,22 @@ public class ExceptionTest {
2828
public void setUp() {
2929
Configuration config = new Configuration("api-key");
3030
ogThrowable = new RuntimeException("Test");
31-
exception = new Exception(config, ogThrowable);
31+
error = new Error(config, ogThrowable);
3232
}
3333

3434
@Test
3535
public void testDefaults() {
36-
assertEquals("java.lang.RuntimeException", exception.getErrorClass());
37-
assertEquals("Test", exception.getMessage());
38-
assertEquals(ogThrowable, exception.getThrowable());
39-
assertFalse(exception.getStacktrace().isEmpty());
36+
assertEquals("java.lang.RuntimeException", error.getErrorClass());
37+
assertEquals("Test", error.getMessage());
38+
assertEquals(ogThrowable, error.getThrowable());
39+
assertFalse(error.getStacktrace().isEmpty());
4040
}
4141

4242
@Test
4343
public void testClassOverride() {
44-
exception.setErrorClass("Hello");
45-
assertEquals("Hello", exception.getErrorClass());
46-
assertEquals("Test", exception.getMessage());
44+
error.setErrorClass("Hello");
45+
assertEquals("Hello", error.getErrorClass());
46+
assertEquals("Test", error.getMessage());
4747
}
4848

4949
@Test
@@ -68,13 +68,13 @@ public void close() {
6868
report.setExceptionName("Foo");
6969
assertEquals("Foo", report.getExceptionName());
7070

71-
List<Exception> exceptions = report.getExceptions();
72-
assertEquals(1, exceptions.size());
71+
List<Error> errors = report.getErrors();
72+
assertEquals(1, errors.size());
7373

74-
Exception exception = exceptions.get(0);
75-
assertNotNull(exception);
76-
assertEquals("Foo", exception.getErrorClass());
77-
assertEquals("Test", exception.getMessage());
74+
Error error = errors.get(0);
75+
assertNotNull(error);
76+
assertEquals("Foo", error.getErrorClass());
77+
assertEquals("Test", error.getMessage());
7878
} catch (Throwable throwable) {
7979
report.cancel();
8080
}

bugsnag/src/test/java/com/bugsnag/ThreadStateTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void testHandledStacktrace() throws IOException {
187187
}
188188

189189
/**
190-
* Verifies that an unhandled error uses {@link com.bugsnag.Exception#getStacktrace()}
190+
* Verifies that an unhandled error uses {@link Error#getStacktrace()}
191191
* for the reporting thread stacktrace
192192
*/
193193
@Test

0 commit comments

Comments
 (0)