1

Is there something similar to the InvalidEnumArgumentException in java?

Usecase:

public FigureType determinateFigureType(int row, int column) throws ??? {
    switch (globalSheet[row][column]) {
        case FIELD_FREE:
            return FigureType.Free;
        case FIELD_A:
            return FigureType.A;
        case FIELD_B:
            return FigureType.B;
        default:
            throw new ???();
    }
}
FireEmerald
  • 1,002
  • 12
  • 21

1 Answers1

2

maybe IllegalArgumentException?

Java API:

Thrown to indicate that a method has been passed an illegal or inappropriate argument.

There is also an EnumConstantNotPresentException, however, this doesn't seem to be what you are looking for.

user7291698
  • 1,972
  • 2
  • 15
  • 30
  • I used an `RuntimeException` now instead of an `IllegalArgumentException`. See http://stackoverflow.com/a/2190177/4300087 for further informations. With a RuntimeException the `throws ???` part can be omitted. – FireEmerald Dec 25 '16 at 17:27
  • 1
    `IllegalArgumentException` is a subclass of `RuntimeException`, therefore you can omit the `throws` as well. – user7291698 Dec 25 '16 at 23:18