summaryrefslogtreecommitdiff
path: root/src/library/scala/MatchError.scala
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-10-19 12:36:19 +0000
committerBurak Emir <emir@epfl.ch>2006-10-19 12:36:19 +0000
commit2cf278b25baf138c0a9775bcbe7bc97b4b548139 (patch)
treee63559465e6f4d8cbefe7259e089e6a56603bf34 /src/library/scala/MatchError.scala
parent00db012c72614355680834516ccd649cf48d63ac (diff)
downloadscala-2cf278b25baf138c0a9775bcbe7bc97b4b548139.tar.gz
scala-2cf278b25baf138c0a9775bcbe7bc97b4b548139.tar.bz2
scala-2cf278b25baf138c0a9775bcbe7bc97b4b548139.zip
fix 781, nullpointerexcs in matcherror
Diffstat (limited to 'src/library/scala/MatchError.scala')
-rw-r--r--src/library/scala/MatchError.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/library/scala/MatchError.scala b/src/library/scala/MatchError.scala
index a26c5087ce..6ef969b97c 100644
--- a/src/library/scala/MatchError.scala
+++ b/src/library/scala/MatchError.scala
@@ -23,13 +23,16 @@ import Predef._
*/
object MatchError {
+ def string(obj: Any) =
+ if(obj != null) obj.toString() else "null"
+
// todo: change pattern matcher so that dummy type parameter T can be removed.
def fail[T](source: String, line: Int): Nothing =
throw new MatchError(source, line)
def report(source: String, line: Int, obj: Any) =
try {
- throw new MatchError(source, line, obj.toString())
+ throw new MatchError(source, line, string(obj))
} catch {
case e: MatchError => throw e
case e: Throwable => throw new MatchError(source, line)
@@ -43,6 +46,6 @@ final class MatchError(msg: String) extends Error(msg) {
def this(source: String, line: Int, obj: String) =
this("for object " + obj + " in '" + source + "' at line " + line)
- def this(ob: Any) =
- this(ob.toString())
+ def this(obj: Any) =
+ this(MatchError.string(obj))
}