开发者

What are Scala standard exceptions?

开发者 https://www.devze.com 2023-04-13 02:04 出处:网络
What are the common standard exceptions in Scala? I am especially intereste开发者_运维百科d in how is .Net\'s NotImplementedException equivalent called?

What are the common standard exceptions in Scala? I am especially intereste开发者_运维百科d in how is .Net's NotImplementedException equivalent called?

UPDATE: The answer about the NotImplementedException seems to be org.apache.commons.lang.NotImplementedException


Almost nothing:

package scala {
  final class MatchError(obj: Any) extends RuntimeException
  final class UninitializedError extends RuntimeException("uninitialized value")
  final case class UninitializedFieldError (msg: String) extends RuntimeException(msg)

  package util.regex {
    class SyntaxError(e: String) extends RuntimeException(e)
  }

  package xml {

    class BrokenException() extends java.lang.Exception
    case class MalformedAttributeException(msg: String) extends RuntimeException(msg)

    package dtd {
      case class ValidationException(e: String) extends Exception(e)
    }

    package include {
      class CircularIncludeException(message: String) extends XIncludeException
      class UnavailableResourceException(message: String) extends XIncludeException(message)
      class XIncludeException(message: String) extends Exception(message)
    }

    package parsing {
      case class FatalError(msg: String) extends java.lang.RuntimeException(msg)
    }
  }
}

The rest comes from Java, which cover pretty much all corners. It begs the question of what these Scala methods throw on other platforms, doesn't it?


The NotImplementedException is currently being considered for Scala 2.10, probably. See this thread.


You can just use whatever default already exists in Java. Scala doesn't really add anything to the standard exceptions in Java.

0

精彩评论

暂无评论...
验证码 换一张
取 消