summaryrefslogtreecommitdiff
path: root/newsources/scala/MatchError.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-12-02 09:40:14 +0000
committerMartin Odersky <odersky@gmail.com>2005-12-02 09:40:14 +0000
commitbc5923e2a9a1322feaeb3d2d3c70c756ec206d6c (patch)
treef622d126243303c4feb8260e0664c6df25d03ab1 /newsources/scala/MatchError.scala
parent1ddf7e4b1551c3229e5191aa3127b93e290f0345 (diff)
downloadscala-bc5923e2a9a1322feaeb3d2d3c70c756ec206d6c.tar.gz
scala-bc5923e2a9a1322feaeb3d2d3c70c756ec206d6c.tar.bz2
scala-bc5923e2a9a1322feaeb3d2d3c70c756ec206d6c.zip
*** empty log message ***
Diffstat (limited to 'newsources/scala/MatchError.scala')
-rwxr-xr-xnewsources/scala/MatchError.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/newsources/scala/MatchError.scala b/newsources/scala/MatchError.scala
new file mode 100755
index 0000000000..4979df8717
--- /dev/null
+++ b/newsources/scala/MatchError.scala
@@ -0,0 +1,40 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+** **
+** $Id$
+\* */
+package scala;
+
+
+/** This class implements errors which are thrown whenever an
+ * object doesn't match any pattern of a pattern matching
+ * expression.
+ *
+ * @author Matthias Zenger
+ * @author Martin Odersky
+ * @version 1.1, 05/03/2004
+ */
+object MatchError {
+
+ // todo: change pattern matcher so that dummy type parameter T can be removed.
+ def fail[T](source: String, line: Int): All = throw new MatchError(source, line);
+
+ def report(source: String, line: Int, obj: Any) =
+ try {
+ throw new MatchError(source, line, obj.toString())
+ } catch {
+ case e: MatchError => throw e
+ case e: Throwable => throw new MatchError(source, line)
+ }
+}
+
+final class MatchError(msg: String) extends Error(msg) {
+ def this(source: String, line: Int) =
+ this(" in '" + source + "' at line " + line);
+ def this(source: String, line: Int, obj: String) =
+ this("for object " + obj + " in '" + source + "' at line " + line);
+}