8000 Improve `s.u.Using` suppression order · scala/scala@8091336 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8091336

Browse files
NthPortallrytz
authored andcommitted
Improve s.u.Using suppression order
Change `scala.util.Using` to have `scala.util.control.ControlThrowable` be suppressed by non-fatal exceptions (`scala.util.control.NonFatal`).
1 parent fd9f761 commit 8091336

File tree

2 files changed

+130
-141
lines changed

2 files changed

+130
-141
lines changed

src/library/scala/util/Using.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ import scala.util.control.{ControlThrowable, NonFatal}
125125
* - `java.lang.LinkageError`
126126
* - `java.lang.InterruptedException` and `java.lang.ThreadDeath`
127127
* - [[scala.util.control.NonFatal fatal exceptions]], excluding `scala.util.control.ControlThrowable`
128+
* - all other exceptions, excluding `scala.util.control.ControlThrowable`
128129
* - `scala.util.control.ControlThrowable`
129-
* - all other exceptions
130130
*
131131
* When more than two exceptions are thrown, the first two are combined and
132132
* re-thrown as described above, and each successive exception thrown is combined
@@ -265,9 +265,9 @@ object Using {
265265
case _: VirtualMachineError => 4
266266
case _: LinkageError => 3
267267
case _: InterruptedException | _: ThreadDeath => 2
268-
case _: ControlThrowable => 0
268+
case _: ControlThrowable => -1 // below everything
269269
case e if !NonFatal(e) => 1 // in case this method gets out of sync with NonFatal
270-
case _ => -1
270+
case _ => 0
271271
}
272272
@inline def suppress(t: Throwable, suppressed: Throwable): Throwable = { t.addSuppressed(suppressed); t }
273273

0 commit comments

Comments
 (0)
0