[Test] Use rethrow for checked exception in java-written tests

In 9b5a9ccb `throws Exception` was removed from java test sources and
  all checked exceptions were wrapped with `RuntimeException`

But it was forgotten that there is a `rethrow` utility, which doesn't
  wrap exception but makes the javac happy at the same time
This commit is contained in:
Dmitriy Novozhilov
2024-03-14 10:02:48 +02:00
committed by Space Team
parent 09c27d78b8
commit f288163cbc
9 changed files with 32 additions and 25 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.test.KtAssert;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import java.io.File;
import java.io.FileNotFoundException;
@@ -94,16 +95,16 @@ public class KtTestUtil {
* This clarifies the exception by showing the full path.
*/
String messageWithFullPath = file.getAbsolutePath() + " (No such file or directory)";
throw new RuntimeException(
new IOException(
"Ensure you have your 'Working Directory' configured correctly as the root " +
"Kotlin project directory in your test configuration\n\t" +
messageWithFullPath,
fileNotFoundException
)
throw ExceptionUtilsKt.rethrow(
new IOException(
"Ensure you have your 'Working Directory' configured correctly as the root " +
"Kotlin project directory in your test configuration\n\t" +
messageWithFullPath,
fileNotFoundException
)
);
} catch (IOException e) {
throw new RuntimeException(e);
throw ExceptionUtilsKt.rethrow(e);
}
}