.... что-то не так :(
package com.javarush.task.task25.task2511;
import java.util.TimerTask;
/*
Вооружаемся до зубов!
*/
public class Solution extends TimerTask {
protected TimerTask original;
protected final Thread.UncaughtExceptionHandler handler;
public Solution(TimerTask original) {
if (original == null) {
throw new NullPointerException();
}
this.original = original;
// this.handler = null; //init handler here
this.handler = new Thread.UncaughtExceptionHandler(){
@Override
public void uncaughtException(Thread t, Throwable e) {
String errTh = e.toString();
String[] words = errTh.split("\\s*(\\s|,|!|\\.)\\s*");
System.out.println(words[0] + "." + words[1] + "." + words[2] + " " + words[3] + " " +
words[4].replaceAll(".","*") + " " + words[5]);
// System.out.println(e);
}
};
}
public void run() {
try {
original.run();
} catch (Throwable cause) {
Thread currentThread = Thread.currentThread();
handler.uncaughtException(currentThread, new Exception("Blah " + currentThread.getName() + " blah-blah-blah", cause));
}
}
public long scheduledExecutionTime() {
return original.scheduledExecutionTime();
}
public boolean cancel() {
return original.cancel();
}
public static void main(String[] args) {
new Solution (new TimerTask() {
@Override
public void run() {
throw new UnsupportedOperationException();
}
}).run();
}
}