QuestionQ29

Secure Coding Practices for Error Handling

Which of the following methods would you use instead of ex.printStackTrace() to avoid printing the stack trace when an error occurs?

  • A ex.StackTrace.getError();
  • B ex.message();
  • C ex.getMessage();
  • D ex.getError();
Explanation

getMessage() retrieves an exception’s detail message without outputting the exception’s stack trace.

Community Discussion

No comments yet. Be the first to start the discussion!