Q: What are some ways to improve exception handling in code to make it more secure?
-
A
Revealing sensitive information in exceptions, catching general exceptions only, and swallowing exceptions.
-
B
Catch the most specific exceptions possible, avoid revealing sensitive information in exceptions, and avoid swallowing exceptions.
-
C
Exposing detailed error information, catching only specific exceptions, and not rethrowing exceptions.
-
D
Using try-catch blocks for every line of code and logging all exceptions to a public server.
B
Answer:
B
Explanation:
Catching specific exceptions allows for targeted handling, avoiding sensitive information in exceptions prevents leaks, and not swallowing exceptions ensures errors are logged or rethrown for debugging.
Related Topic:
Share Above MCQ