The behavior of throwing an exception is relatively recent, tbh (Compose 1.7 I belive ?). It surprised a bunch of people when they changed the behavior to start throwing, me included.
Comments
Log in with your Bluesky account to leave a comment
I mean it's not entirely wrong: either you verified that it's a proper URL and you're just lacking something to open it (which is runtime only), or you're getting a wrong URL, which is also runtime only.
IllegalArgumentException does feel kind of wrong, but I don't see anything more appropriate
Ah, I remember! It always threw, but it used to be an ActivityNotFoundException, and was changed for KMP compatibility, which surprised a bunch of people
IllegalArgument is right for preconditions, which require is good for. Is it really a precondition, or a normal, expectable state of failure ? :D
Comments
Perks of having to work in a sector where everything is fragmented and everyone wants their own app 🫠
IllegalArgumentException does feel kind of wrong, but I don't see anything more appropriate
You'd probably also fail your own functions with the same exceptions for bad input. Kotlin's require() throws this exception as well when it throws.
IllegalArgument is right for preconditions, which require is good for. Is it really a precondition, or a normal, expectable state of failure ? :D