- Java try catch 输出报错(包含类名、方法名、行号)
try{ throw new Exception(); }catch (Exception exp){ String errorStr = "error: " + this.getClass().getName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName() + "() line:" + exp.getStackTrace()[0].getLineNumber() + "\n" + exp.toString(); System.out.println(errorStr); }
标签:Java,try,报错,exp,catch,类名 From: https://www.cnblogs.com/hghdbk/p/16807086.html