什么是 Scala 标准异常?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7744690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are Scala standard exceptions?
提问by Ivan
What are the common standard exceptions in Scala?
I am especially interested in how is .Net's NotImplementedExceptionequivalent called?
Scala 中常见的标准异常是什么?我对 .Net 的NotImplementedException等价物如何称呼特别感兴趣?
UPDATE: The answer about the NotImplementedExceptionseems to be
org.apache.commons.lang.NotImplementedException
更新:关于org.apache.commons.lang.NotImplementedException的答案NotImplementedException似乎是
采纳答案by Daniel C. Sobral
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?
其余的来自 Java,它几乎涵盖了所有方面。它回避了这些 Scala 方法在其他平台上抛出什么的问题,不是吗?
回答by axel22
回答by Kim Stebel
You can just use whatever default already exists in Java. Scala doesn't really add anything to the standard exceptions in Java.
您可以使用 Java 中已经存在的任何默认值。Scala 并未真正向 Java 中的标准异常添加任何内容。

