Sonar: Preserve Stack Trace
Sonar: Preserve Stack Trace
New exception is thrown in catch block, original stack trace may be lost
} catch (XPathExpressionException e) {
throw new SAMLNoFoundException(e.getMessage(), e.fillInStackTrace());
}
Solution:
} catch (XPathExpressionException e) {
throw e;
}
Written by Jaime Pérez Halcón
Related protips
2 Responses
Nested exception constructor doesn't works for Sonar default rule?
What if you want to explicitely throw SAMLNoFoundException
(or WhateverMyException
) and not XPathExpressionException
?
over 1 year ago
·
Good question, try:
} catch (XPathExpressionException e) {
throw new SAMLNoFoundException("MESSAGE", e);
}
It does not fail.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Exception
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#