Created
January 8, 2022 20:55
-
-
Save optimho/527f3090dc4a3f6994788c54174286fd to your computer and use it in GitHub Desktop.
Create and throw an exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.temporal.TemporalAmount | |
| import kotlin.reflect.typeOf | |
| fun main(args: Array<String>) { | |
| val p:Person = Person("Michael", 10) | |
| if (p.age<12){ | |
| throw InvalidAgeException(p.age, "WTF dude") | |
| } | |
| } | |
| class InvalidAgeException(val age: Int, override val message: String): IllegalArgumentException("Invalid Age: $age, $message"){} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment