Files
kotlin-fork/libraries/stdlib/js/irRuntime/exceptions.kt
T
Anton Bannykh 8e347f9f39 [JS IR BE] lateinit support
* Functions with IrExpressionBody are lowered to IrBlockBody
* Implemented throwUninitializedPropertyAccessException function
2018-09-21 18:20:11 +03:00

105 lines
4.0 KiB
Kotlin

/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package kotlin
open class Error(override val message: String?, override val cause: Throwable?) : Throwable() {
constructor() : this(null, null)
constructor(_message: String?) : this(_message, null)
constructor(_cause: Throwable?) : this(null, _cause)
}
open class Exception(override val message: String?, override val cause: Throwable?) : Throwable() {
constructor() : this(null, null)
constructor(_message: String?) : this(_message, null)
constructor(_cause: Throwable?) : this(null, _cause)
}
open class RuntimeException(message: String?, cause: Throwable?) : Exception(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(null, cause)
}
open class IllegalArgumentException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(null, cause)
}
open class IllegalStateException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(null, cause)
}
open class ClassCastException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
}
open class NullPointerException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
}
open class IndexOutOfBoundsException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
}
open class AssertionError(message: String?, cause: Throwable?) : Exception(message, cause) {
constructor() : this(null, null)
constructor(message: Any?) : this(message?.toString(), message as? Throwable)
}
open class UnsupportedOperationException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(null, cause)
}
open class NoSuchElementException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
}
open class NumberFormatException(message: String?) : IllegalArgumentException(message) {
constructor() : this(null)
}
public open class NoWhenBranchMatchedException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(undefined, cause)
}
open class UninitializedPropertyAccessException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
constructor() : this(null, null)
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(undefined, cause)
}
@SinceKotlin("1.3")
open class ArithmeticException constructor(message: String?) : RuntimeException(message) {
constructor() : this(null)
}
// TODO: fix function names to satisfy style convention (depends on built-in names)
fun THROW_ISE() {
throw IllegalStateException()
}
fun THROW_CCE() {
throw ClassCastException()
}
fun THROW_NPE() {
throw NullPointerException()
}
fun error(s: String): Nothing = throw IllegalStateException(s, null)
@PublishedApi
internal fun throwUninitializedPropertyAccessException(name: String): Nothing =
throw UninitializedPropertyAccessException("lateinit property $name has not been initialized")