JS backend: made some exceptions more JS idiomatic -- translate Exception to Error, IndexOutOfBounds and IndexOutOfBoundsException to RangeError.
This commit is contained in:
@@ -3,8 +3,8 @@ package java.lang
|
||||
import java.io.IOException
|
||||
import js.library
|
||||
|
||||
library
|
||||
open public class Exception(message: String? = null) : Throwable() {}
|
||||
native("Error")
|
||||
open public class Exception(message: String? = null): Throwable() {}
|
||||
|
||||
library
|
||||
open public class RuntimeException(message: String? = null) : Exception(message) {}
|
||||
@@ -15,8 +15,11 @@ public class IllegalArgumentException(message: String? = null) : Exception() {}
|
||||
library
|
||||
public class IllegalStateException(message: String? = null) : Exception() {}
|
||||
|
||||
library
|
||||
public class IndexOutOfBoundsException(message: String? = null) : Exception() {}
|
||||
native("RangeError")
|
||||
public class IndexOutOfBounds(message: String? = null) : Exception(message) {}
|
||||
|
||||
native("RangeError")
|
||||
public class IndexOutOfBoundsException(message: String? = null) : Exception(message) {}
|
||||
|
||||
library
|
||||
public class UnsupportedOperationException(message: String? = null) : Exception() {}
|
||||
|
||||
@@ -72,16 +72,13 @@ String.prototype.contains = function (s) {
|
||||
|
||||
Kotlin.modules = {};
|
||||
|
||||
Kotlin.Exception = Kotlin.$createClass();
|
||||
Kotlin.RuntimeException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.IndexOutOfBounds = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.NullPointerException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.NoSuchElementException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.IllegalArgumentException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.IllegalStateException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.IndexOutOfBoundsException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.UnsupportedOperationException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.IOException = Kotlin.$createClass(Kotlin.Exception);
|
||||
Kotlin.RuntimeException = Kotlin.$createClass();
|
||||
Kotlin.NullPointerException = Kotlin.$createClass();
|
||||
Kotlin.NoSuchElementException = Kotlin.$createClass();
|
||||
Kotlin.IllegalArgumentException = Kotlin.$createClass();
|
||||
Kotlin.IllegalStateException = Kotlin.$createClass();
|
||||
Kotlin.UnsupportedOperationException = Kotlin.$createClass();
|
||||
Kotlin.IOException = Kotlin.$createClass();
|
||||
|
||||
Kotlin.throwNPE = function () {
|
||||
throw Kotlin.$new(Kotlin.NullPointerException)();
|
||||
@@ -263,7 +260,7 @@ String.prototype.contains = function (s) {
|
||||
},
|
||||
checkRange: function(index) {
|
||||
if (index < 0 || index >= this.$size) {
|
||||
throw new Kotlin.IndexOutOfBoundsException();
|
||||
throw new RangeError();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user