From c20df35c786ed12293624b9bbd980a6ab72d9b83 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Thu, 17 Nov 2016 17:56:34 +0300 Subject: [PATCH] Exception classes (#68) --- runtime/src/main/kotlin/kotlin/Exceptions.kt | 139 +++++++++++++++++++ runtime/src/main/kotlin/kotlin/Throwable.kt | 7 + 2 files changed, 146 insertions(+) create mode 100644 runtime/src/main/kotlin/kotlin/Exceptions.kt diff --git a/runtime/src/main/kotlin/kotlin/Exceptions.kt b/runtime/src/main/kotlin/kotlin/Exceptions.kt new file mode 100644 index 00000000000..0effb03329d --- /dev/null +++ b/runtime/src/main/kotlin/kotlin/Exceptions.kt @@ -0,0 +1,139 @@ +package kotlin + +public open class Error : Throwable { + + constructor() : super() { + } + + constructor(message: String) : super(message) { + } + + constructor(message: String, cause: Throwable) : super(message, cause) { + } + + constructor(cause: Throwable) : super(cause) { + } +} + +public open class Exception : Throwable { + + constructor() : super() { + } + + constructor(message: String) : super(message) { + } + + constructor(message: String, cause: Throwable) : super(message, cause) { + } + + constructor(cause: Throwable) : super(cause) { + } +} + +public open class RuntimeException : Exception { + + constructor() : super() { + } + + constructor(message: String) : super(message) { + } + + constructor(message: String, cause: Throwable) : super(message, cause) { + } + + constructor(cause: Throwable) : super(cause) { + } +} + +public class NullPointerException : RuntimeException { + + constructor() : super() { + } + + constructor(s: String) : super(s) { + } +} + +public class NoSuchElementException : RuntimeException { + + constructor() : super() { + } + + constructor(s: String) : super(s) { + } +} + +public class IllegalArgumentException : RuntimeException { + + constructor() : super() { + } + + constructor(s: String) : super(s) { + } + + constructor(message: String, cause: Throwable) : super(message, cause) { + } + + constructor(cause: Throwable) : super(cause) { + } +} + +public class IllegalStateException : RuntimeException { + + constructor() : super() { + } + + constructor(s: String) : super(s) { + } + + constructor(message: String, cause: Throwable) : super(message, cause) { + } + + constructor(cause: Throwable) : super(cause) { + } +} + +public class UnsupportedOperationException : RuntimeException { + + constructor() { + } + + constructor(message: String) : super(message) { + } + + constructor(message: String, cause: Throwable) : super(message, cause) { + } + + constructor(cause: Throwable) : super(cause) { + } +} + +public class IndexOutOfBoundsException : RuntimeException { + + constructor() : super() { + } + + constructor(s: String) : super(s) { + } +} + +public class ClassCastException : RuntimeException { + + constructor() : super() { + } + + constructor(s: String) : super(s) { + } +} + +public class AssertionError : Error { + + constructor() { + } + + constructor(message: String) : super(message) { + } + + constructor(message: String, cause: Throwable) : super(message, cause) { + } +} \ No newline at end of file diff --git a/runtime/src/main/kotlin/kotlin/Throwable.kt b/runtime/src/main/kotlin/kotlin/Throwable.kt index f2bc07cdd8a..0bca7ee392e 100644 --- a/runtime/src/main/kotlin/kotlin/Throwable.kt +++ b/runtime/src/main/kotlin/kotlin/Throwable.kt @@ -12,4 +12,11 @@ public open class Throwable(open val message: String?, open val cause: Throwable constructor(cause: Throwable?) : this(cause?.toString(), cause) constructor() : this(null, null) + + override fun toString(): String { + /* enable, once codegen is improved. + val s = "Throwable" + return if (message != null) s + ": " + message.toString() else s */ + return "Throwable" + } }