In Java, I have a class with a few methods that throw the same custom exception (the custom exception extends the 'Exception' class):
private void setAColor(float r, float g, float b, float a) throws AnException {}
private void setBColor(float r, float g, float b, float a) throws AnException {}
private void setCColor(float r, float g, float b, float a) throws AnException {}
Instead of having the user handle these exceptions, I would like to be able to catch them and handle them within the class. Each method exception will be caught in the exact same way. I do not want to have to put the exact same try/catch method block in every single method. Is there a way I can catch these exceptions outside of the body of the methods, but inside of the class?
Thank you for your time, even if you cannot help me.
APPENDING MORE INFORMATION:
These methods may be called up until a certain point: After a method is called that sets the variable "isImmutable" to true, these methods should no longer be able to change anything about the object. Hence, if one of these methods are called after "isImmutable" is set to true, then they should throw an exception called "ImmutableException". For /this particular implementation/, I want to be able to handle these myself instead of going to every single point in the code that these methods are called and handling them then exact same way.