mirror of
https://github.com/signalapp/libsignal.git
synced 2024-09-20 03:52:17 +02:00
java: include unexpected exception name in message
This commit is contained in:
parent
9a6898a136
commit
7c8a3e957d
@ -66,8 +66,9 @@ public class FilterExceptions {
|
||||
}
|
||||
|
||||
private static AssertionError reportUnexpectedException(Exception e) {
|
||||
Log.e("libsignal", "Unexpected checked exception " + e.getClass(), e);
|
||||
return new AssertionError(e);
|
||||
String message = "Unexpected checked exception " + e.getClass();
|
||||
Log.e("libsignal", message, e);
|
||||
return new AssertionError(message, e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,39 @@
|
||||
//
|
||||
// Copyright 2024 Signal Messenger, LLC.
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
package org.signal.libsignal.media;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.signal.libsignal.internal.FilterExceptions.filterExceptions;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.signal.libsignal.internal.FilterExceptions.ThrowingNativeVoidOperation;
|
||||
|
||||
public class FilterExceptionsTest {
|
||||
|
||||
private static class UnexpectedException extends Exception {
|
||||
public UnexpectedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionTextIncludesClass() {
|
||||
AssertionError error =
|
||||
assertThrows(
|
||||
AssertionError.class,
|
||||
() -> {
|
||||
filterExceptions(
|
||||
(ThrowingNativeVoidOperation)
|
||||
() -> {
|
||||
throw new UnexpectedException("not expected");
|
||||
});
|
||||
});
|
||||
|
||||
assertThat(error.getMessage(), containsString("FilterExceptionsTest$UnexpectedException"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user