问问题
181 次
1 回答
0
一旦我有一个名为NubLogger
处理此类问题的类。不要问名字的选择...
public static void handle(Throwable t) {
if (t == null) {
t = new Throwable(NubLogger.class.getName() + ".handle((Throwable)null)");
}
if (t instanceof RuntimeException) {
log(t);
throw (RuntimeException) t;
} else if (t instanceof Exception) {
log(t);
throw new RuntimeException(t);
} else if (t instanceof Error) {
log(t);
throw (Error) t;
} else if (t instanceof Throwable) {
log(t);
throw new RuntimeException(t);
} else {
t = new UnsupportedOperationException("Unknown throwable type: " + t.getClass(), t);
log(t);
throw (RuntimeException)t;
}
}
编辑
class Element (var name:String){
// VALIDAZIONE DI ELEMENT
// Preferrable variant - use val name, not var name
require(name != null)
// VALIDAZIONE DI ELEMENT 2
// Will work with var-s
def validate = name != null
}//class Element
于 2012-12-10T22:19:55.467 回答