I\'ve been updating an existing library to throw exceptions to help improve debugging by people using the library.
At first, I thought I\'d define exceptions specific to
Here's my take on why we have different types of exception and when to create custom exception types (note: this uses .NET types as examples but the same principles apply to Java and any other language that uses structured error handling). It's probably too long to post here as a complete answer so I'll just post the two key extracts.
When to throw different types of exception? Throw a different type of exception for each symptom that can be programmatically handled differently.
When to create custom exception types? Create a custom exception type when you need to annotate the exception with additional information to aid in the programmatic handling of the symptom.
In your case it doesn't sound like your custom exception types are filling a gap in the symptoms that can be conveyed using standard exceptions, and they aren't adding any additional information for programmatic handling, so don't create them. Just use standard ones instead.