# Run-time exceptions

**URL:** <https://forum.vassalengine.org/t/run-time-exceptions/223>\
**Category:** Development\
**Created:** [February 1, 2008, 6:40pm UTC](https://forum.vassalengine.org/t/run-time-exceptions/223 "2008-02-01T18:40:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkiefte](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/mkiefte/32/25_2.png) [@mkiefte](https://forum.vassalengine.org/u/mkiefte)\
**Post date:** [February 1, 2008, 6:40pm UTC](https://forum.vassalengine.org/t/run-time-exceptions/223/1 "2008-02-01T18:40:21Z")

</div>

What’s the best way to handle run-time exceptions that really can’t possibly be the fault of anyone but the developers?

I’m calling Class.newInstance() which throws IllegalAccessException or InstantiationException. However, if it throws either of these, then it’s because of the developer, not something that any module writer or player has done. Right now, there’s only three possible classes that it can be.

This is something that would ideally be checked at compile time, but obviously it can’t. Should I just leave the catch blocks empty, or should I call some error log function?

---

<div class="post-metadata">

**Author:** ![uckelman](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/uckelman/32/10020_2.png) [@uckelman](https://forum.vassalengine.org/u/uckelman)\
**Post date:** [February 1, 2008, 7:54pm UTC](https://forum.vassalengine.org/t/run-time-exceptions/223/2 "2008-02-01T19:54:19Z")

</div>

Thus spake “mkiefte”:

> [@](#):
>
> What’s the best way to handle run-time exceptions that really can’t possibly  
> be the fault of anyone but the developers?
> 
> I’m calling Class.newInstance() which throws IllegalAccessException or Instan  
> tiationException. However, if it throws either of these, then it’s because of  
> the developer, not something that any module writer or player has done. Rig  
> ht now, there’s only three possible classes that it can be.
> 
> This is something that would ideally be checked at compile time, but obviousl  
> y it can’t. Should I just leave the catch blocks empty, or should I call som  
> e error log function?

If it’s an unchecked exception, then just let it go all the way to the  
exception handler—that will pop up a dialog alerting the user to tell  
us about it.

If it’s a checked exception—i.e., one you have to catch somewhere—  
you should at least call printStackTrace(), otherwise we have no chance  
of ever finding out what’s gone wrong. Additionally, you might want  
to call ErrorLog.warn().

–  
J.

* * *

Messages mailing list  
[Messages@forums.vassalengine.org](mailto:Messages@forums.vassalengine.org)  
[forums.vassalengine.org/mailman/ … engine.org](http://forums.vassalengine.org/mailman/listinfo/messages_forums.vassalengine.org)

Post generated using Mail2Forum ([mail2forum.com](http://www.mail2forum.com))
