In the example provided in the article, we have created CustomError model class which has msg and errorCode as parameters.
So while throwing exceptions we can set different msg for different context
CustomError error = new CustomError();
error.setErrorCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
error.sets("Arithmetic exception thrown " + ae.getLocalizedMessage());
Here error.sets(any custom msg) can be used to set custom mags.