Create custom exception for lateinit

This commit is contained in:
Yan Zhulanow
2015-09-04 17:13:55 +03:00
parent fc3bf3cca4
commit 4ca127ecb3
8 changed files with 38 additions and 7 deletions
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin
public class UninitializedPropertyAccessException(name: String): RuntimeException("lateinit property $name has not been initialized")
@@ -17,6 +17,7 @@
package kotlin.jvm.internal;
import kotlin.KotlinNullPointerException;
import kotlin.UninitializedPropertyAccessException;
import java.util.Arrays;
import java.util.List;
@@ -34,6 +35,10 @@ public class Intrinsics {
throw sanitizeStackTrace(new KotlinNullPointerException());
}
public static void throwUninitializedPropertyAccessException(String propertyName) {
throw sanitizeStackTrace(new UninitializedPropertyAccessException(propertyName));
}
public static void checkExpressionValueIsNotNull(Object value, String message) {
if (value == null) {
IllegalStateException exception = new IllegalStateException(message + " must not be null");