Rethrow Loses Stack Trace (ARCH4154)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key java.logging.rethrow-without-cause · Severity warning · Category logging
Throwing a new exception inside a handler without passing the original as the cause destroys the stack trace leading to the root cause. The true source of the error is lost and diagnosis becomes very hard.
Incorrect
Section titled “Incorrect”try { return repository.load(id);} catch (SQLException e) { throw new ServiceException("Load failed");}Correct
Section titled “Correct”try { return repository.load(id);} catch (SQLException e) { throw new ServiceException("Load failed", e);}Pass the original exception as the cause argument when constructing the new exception.