JnCrMx / discord-game-sdk4j

Java bindings for Discord's Game SDK
MIT License
114 stars 23 forks source link

Add Core#isOpen public method, add CoreClosedException #41

Closed chrislo27 closed 2 years ago

chrislo27 commented 2 years ago

The open AtomicBoolean field in Core is not publicly gettable, so I added a boolean getter Core#isOpen(). Additionally, I subclassed IllegalStateException and created CoreClosedException which is easier to catch for than a plain IllegalStateException.

My rationale for this change is that any of the SDK methods that eventually call (the package-private) Core#execute method may throw an IllegalArgumentException if the Core is unexpectedly closed. I would prefer to avoid exception-based handling as a user of this library, so being able to check if the Core is open or not is useful. The CoreClosedException was my original plan since I could catch-filter for it, but I think both options are flexible.

JnCrMx commented 2 years ago

Both changes look very useful and good to me. Thank you a lot for your contribution! :D