New answers tagged

1 vote

Java Exception Error Enumerations Anti-pattern

Every time some new exception conditional is dreamed up, then the enumeration has to be updated. Well, this question is slightly orthogonal to exceptions. If you have a (large) set of error codes, do ...
  • 7,363
0 votes

Java Exception Error Enumerations Anti-pattern

Usually an enum should have few values, but in the end as many as needed. For example an enum for specifying system colours could have a large number of values, but that isn’t a problem. One enum ...
  • 40.4k
2 votes

Java Exception Error Enumerations Anti-pattern

So much work when it could just be: public class InvalidDataFormatException extends GenericExampleException {} public class MissingRequiredFieldException extends GenericExampleException {} public ...
3 votes
Accepted

Java Exception Error Enumerations Anti-pattern

It implies callers should explicitly deal with each possible type, which makes the client exception handling tedious. Yes, your calling code has to catch each and every Exception, then work out (from ...
  • 11.8k
5 votes

Java Exception Error Enumerations Anti-pattern

You haven't talked about proposed alternatives to this approach so I'll answer in generalities that may not be relevant to you in a particular situation. Usually, I would expect something like this ...
  • 24.5k

Top 50 recent answers are included