Skip to content

Commit

Permalink
Throw exception instead of return null
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Litwiniuk committed Oct 24, 2024
1 parent 59df612 commit 835dd1d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public List<String> getAttachmentPaths() {
public List<String> getAttachments() {
return this.getAttachmentPaths();
}

public Map<String, ThreadInformation> getThreadInformationMap() {
return threadInformationMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public BacktraceStackFrame(StackTraceElement frame) {
*/
public static BacktraceStackFrame fromStackTraceElement(StackTraceElement frame) {
if (frame == null || frame.getMethodName() == null) {
BacktraceLogger.w(LOG_TAG, "Frame or method name is null");
return null;
BacktraceLogger.e(LOG_TAG, "Frame or method name is null");
throw new IllegalArgumentException("Frame or method name is null");
}
final String functionName = frame.getClassName() + "." + frame.getMethodName();
final String fileName = frame.getFileName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ public void serializeFromStackTraceElement() {
assertEquals(expectedJson, json);
}

@Test
@Test(expected = IllegalArgumentException.class)
public void createFromNullStackTraceElement() {
// GIVEN
BacktraceStackFrame obj = BacktraceStackFrame.fromStackTraceElement(null);
// THEN
assertNull(obj);
}

@Test
Expand Down

0 comments on commit 835dd1d

Please sign in to comment.