Introduce NotImplementedError instead of UnsupportedOperationException to throw from TODO function.
#KT-8153
This commit is contained in:
@@ -1,17 +1,21 @@
|
|||||||
package kotlin
|
package kotlin
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always throws an [UnsupportedOperationException] stating that operation is not implemented.
|
* An exception is thrown to indicate that a method body remains to be implemented.
|
||||||
*/
|
*/
|
||||||
public fun TODO(): Nothing = throw UnsupportedOperationException("An operation is not implemented.")
|
public class NotImplementedError(message: String = "An operation is not implemented.") : Error(message)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always throws an [UnsupportedOperationException] stating that operation is not implemented.
|
* Always throws [NotImplementedError] stating that operation is not implemented.
|
||||||
|
*/
|
||||||
|
public fun TODO(): Nothing = throw NotImplementedError()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always throws [NotImplementedError] stating that operation is not implemented.
|
||||||
*
|
*
|
||||||
* @param reason a string explaining why the implementation is missing.
|
* @param reason a string explaining why the implementation is missing.
|
||||||
*/
|
*/
|
||||||
public fun TODO(reason: String): Nothing = throw UnsupportedOperationException("An operation is not implemented: $reason")
|
public fun TODO(reason: String): Nothing = throw NotImplementedError("An operation is not implemented: $reason")
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ private class PartiallyImplementedClass {
|
|||||||
|
|
||||||
class TODOTest {
|
class TODOTest {
|
||||||
private fun assertNotImplemented(block: () -> Unit) {
|
private fun assertNotImplemented(block: () -> Unit) {
|
||||||
assertTrue(fails(block) is UnsupportedOperationException)
|
assertTrue(fails(block) is NotImplementedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assertNotImplementedWithMessage(message: String, block: () -> Unit) {
|
private fun assertNotImplementedWithMessage(message: String, block: () -> Unit) {
|
||||||
val e = fails(block)
|
val e = fails(block)
|
||||||
assertTrue(e is UnsupportedOperationException)
|
assertTrue(e is NotImplementedError)
|
||||||
assertTrue(message in e!!.getMessage()!!)
|
assertTrue(message in e!!.getMessage()!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user