So I have function that formats a date to coerce to given enum DateType{CURRENT, START, END} what would be the best way to handling return value with cases that use switch stat
I think that throw new IllegalArgumentException("Something strange happend")
is the best pratice.
Using null
will just presumibly cause a NullPointerException
somewhere when you use the return value but it will be less informative than raising a specific exception that describes the problem!
And you know: clear errors = better developing.