ews-java-api icon indicating copy to clipboard operation
ews-java-api copied to clipboard

Remove generic thrown Exceptions

Open dotCipher opened this issue 10 years ago • 2 comments
trafficstars

Many of the calls that exist throw generic Exceptions. It would be nice to have more specific Exceptions thrown for any given call.

Generally it would seem that having more verbose / specific exceptions relating to any given error that happens would be better practice (even if it can get a bit messy sometimes).

See Don't Throw Generic Exceptions and Beware the dangers of throwing generic exceptions.

If this was a design choice that's fine. I just wanted to flag this.

dotCipher avatar Apr 02 '15 23:04 dotCipher

Definitely very ugly. It makes proper error handling impossible or at least a pain in the ass. If you want to not handle the error where the method is used and you rethrow, then it will litter the whole call chain with "throws Exception". Workaround: catch where it occurs and wrap into a new EwsException. But it's only a workaround. You still can't distinguish the various error classes this way.

oglueck avatar Nov 30 '15 08:11 oglueck

If you're going to throw a "we don't know what could possibly go wrong" exception, we would prefer a runtime exception.

Throwing Exception forces downstream code to deal with InterruptedException which is particularly nasty.

hakanai avatar Oct 24 '19 02:10 hakanai