ravi pardeshi wrote:then how come i will show exact problem to user ?
i.e. file not found at specific location
If getCause() returns null, then basically it means that, as far as the exception is concerned, it is the root cause. It may not be, but then the programmer forgot to set the cause and you can never retrieve it anymore.
calls the toString() method on your ex object.
If you look at the source code for the org.springframework.mail.MailSendException class, you can see how toString gets its list of nexted exceptions and then do the same yourself.