Skip to content

Commit 47af6d7

Browse files
committed
Prefer RuntimeException for runtime exceptions
1 parent 6f03d7a commit 47af6d7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

library/src/scala/collection/immutable/HashMap.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ private final class BitmapIndexedMapNode[K, +V](
13101310
}
13111311
}
13121312
case _: HashCollisionMapNode[_, _] =>
1313-
throw new Exception("Cannot merge BitmapIndexedMapNode with HashCollisionMapNode")
1313+
throw new RuntimeException("Cannot merge BitmapIndexedMapNode with HashCollisionMapNode")
13141314
}
13151315

13161316
override def equals(that: Any): Boolean =
@@ -2061,7 +2061,7 @@ private final class HashCollisionMapNode[K, +V ](
20612061
i += 1
20622062
}
20632063
case _: BitmapIndexedMapNode[K, V1] =>
2064-
throw new Exception("Cannot merge HashCollisionMapNode with BitmapIndexedMapNode")
2064+
throw new RuntimeException("Cannot merge HashCollisionMapNode with BitmapIndexedMapNode")
20652065

20662066
}
20672067

library/src/scala/collection/mutable/ArrayBuffer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ object ArrayBuffer extends StrictOptimizedSeqFactory[ArrayBuffer] {
317317
* - Throws an exception if `targetLen` exceeds `VM_MaxArraySize` or is negative (overflow).
318318
*/
319319
private[mutable] def resizeUp(arrayLen: Int, targetLen: Int): Int =
320-
if (targetLen < 0) throw new Exception(s"Overflow while resizing array of array-backed collection. Requested length: $targetLen; current length: $arrayLen; increase: ${targetLen - arrayLen}")
320+
if (targetLen < 0) throw new RuntimeException(s"Overflow while resizing array of array-backed collection. Requested length: $targetLen; current length: $arrayLen; increase: ${targetLen - arrayLen}")
321321
else if (targetLen <= arrayLen) -1
322-
else if (targetLen > VM_MaxArraySize) throw new Exception(s"Array of array-backed collection exceeds VM length limit of $VM_MaxArraySize. Requested length: $targetLen; current length: $arrayLen")
322+
else if (targetLen > VM_MaxArraySize) throw new RuntimeException(s"Array of array-backed collection exceeds VM length limit of $VM_MaxArraySize. Requested length: $targetLen; current length: $arrayLen")
323323
else if (arrayLen > VM_MaxArraySize / 2) VM_MaxArraySize
324324
else math.max(targetLen, math.max(arrayLen * 2, DefaultInitialSize))
325325

0 commit comments

Comments
 (0)