001
014
015 package com.liferay.portal.test.rule;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.test.rule.callback.LogAssertionTestCallback;
020
021 import java.lang.Thread.UncaughtExceptionHandler;
022
023
026 public class LogAssertionUncaughtExceptionHandler
027 implements UncaughtExceptionHandler {
028
029 public LogAssertionUncaughtExceptionHandler(
030 UncaughtExceptionHandler uncaughtExceptionHandler) {
031
032 _uncaughtExceptionHandler = uncaughtExceptionHandler;
033 }
034
035 @Override
036 public void uncaughtException(Thread thread, Throwable throwable) {
037 if (_uncaughtExceptionHandler != null) {
038 _uncaughtExceptionHandler.uncaughtException(thread, throwable);
039 }
040
041 StringBundler sb = new StringBundler(4);
042
043 sb.append("Uncaught exception in ");
044 sb.append(thread);
045 sb.append(StringPool.COMMA_AND_SPACE);
046 sb.append(throwable);
047
048 LogAssertionTestCallback.caughtFailure(
049 new AssertionError(sb.toString(), throwable));
050 }
051
052 private final UncaughtExceptionHandler _uncaughtExceptionHandler;
053
054 }