It depends. If this is the code that you have or have access to, and the BindException is not suitable, you must create your own exceptions:
public class PermissionDeniedException
You can even do:
public class PermissionDeniedBindException extends BindException
However, if this is not your class, then either the library you are using does not want you to distinguish BindException and expect that you will behave in a certain way when an exception is thrown (i.e. just continue or always try again) OR this The problem is in the SDK. If it comes later, and this project is open source, I would recommend creating a migration request.
Otherwise, the third option, of course, will do the same as your case ... but I would not recommend it at all, since it is extremely fragile and can only change by changing the message.
stevebot
source share