Merge pull request #7652 from xuwei-k/ThreadDeath-1

update ErrorHandling.scala. avoid reference deprecated `ThreadDeath`
This commit is contained in:
adpi2 2024-09-12 16:34:26 +02:00 committed by GitHub
commit e3b628621f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -23,9 +23,16 @@ object ErrorHandling {
try {
Right(f)
} catch {
case ex @ (_: Exception | _: StackOverflowError) => Left(ex)
case err @ (_: ThreadDeath | _: VirtualMachineError) => throw err
case x: Throwable => Left(x)
case ex @ (_: Exception | _: StackOverflowError) =>
Left(ex)
case err: VirtualMachineError =>
throw err
case err if err.getClass.getName == "java.lang.ThreadDeath" =>
// ThreadDeath is deprecated
// https://bugs.openjdk.org/browse/JDK-8289610
throw err
case x: Throwable =>
Left(x)
}
def convert[T](f: => T): Either[Exception, T] =