Is it good to have a class with short methods used to catch Exceptions?
class ContractUtils{
  public static String getCode(Contract contract) throws MyException{
    try{
      return contract.getInfo().getCode(); //throws ContractException and LogicException
    }catch(Exception e){
      throw new MyException("error during code reading:"+e.getMessage, e);
    }
  }
  //other methods like above...
}
                If a custom exception provides additional context or value to the calling code, then it's useful and encouraged to create them.
You're approach to using static methods is totally acceptable. Here's a good SO answer defining use cases for short static methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With