You're right - that is something to think carefully about. I think it's best to be as specific as possible. You can catch multiple types of Exception at once with syntax like this:
catch (IOException|SQLException e){...}
The only time I would catch Exception is when calling into code that you have no idea about. For example if you are allowing users to provide plugins to your app or something like that.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You're right - that is something to think carefully about. I think it's best to be as specific as possible. You can catch multiple types of Exception at once with syntax like this:
catch (IOException|SQLException e){...}
The only time I would catch
Exception
is when calling into code that you have no idea about. For example if you are allowing users to provide plugins to your app or something like that.