0
0
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:
Alex Konradi 2024-08-13 14:05:59 -04:00 committed by GitHub
parent 9a6898a136
commit 7c8a3e957d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 2 deletions

View File

@ -66,8 +66,9 @@ public class FilterExceptions {
} }
private static AssertionError reportUnexpectedException(Exception e) { private static AssertionError reportUnexpectedException(Exception e) {
Log.e("libsignal", "Unexpected checked exception " + e.getClass(), e); String message = "Unexpected checked exception " + e.getClass();
return new AssertionError(e); Log.e("libsignal", message, e);
return new AssertionError(message, e);
} }
/** /**

View File

@ -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"));
}
}