Skip to content

Commit e1aed72

Browse files
committed
Use require instead of raw throws for validation requirements
1 parent 05b7351 commit e1aed72

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

Base/src/main/scala/CodePoint.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import scala.math.Ordering
66
* Represents a unicode codepoint
77
*/
88
final class CodePoint private (val intValue:Int) {
9-
if (! Character.isValidCodePoint(intValue)) throw new IllegalArgumentException(s"$intValue")
9+
require(Character.isValidCodePoint(intValue), s"$intValue is not a valid codepoint")
1010

1111
override def toString:String = new String(Array[Int](intValue), 0, 1)
1212
override def hashCode:Int = intValue

TimeParser/src/main/scala/Digit.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ final class Digits(val value:Int)
99

1010
object Digit {
1111
def apply(x:Char):Digit = {
12-
if ('0' <= x && x <= '9') {
13-
new Digit(x - '0')
14-
} else {
15-
throw new IllegalArgumentException("Expected ascii digit")
16-
}
12+
require('0' <= x && x <= '9', "Expected ascii digit")
13+
new Digit(x - '0')
1714
}
1815

1916
implicit def given_Repeated:Repeated[Digit, Digits] = new Repeated[Digit, Digits]{

0 commit comments

Comments
 (0)