Java try catch 输出报错(包含类名、方法名、行号)
- Java try catch 输出报错(包含类名、方法名、行号)
try { throw new Exception(); } catch (Exception exp) { String errorStr = "error: " + exp.getStackTrace()[0].getClassName() + "." + exp.getStackTrace()[0].getMethodName() + "() line:" + exp.getStackTrace()[0].getLineNumber() + "\n" + exp.toString(); System.out.println(errorStr); }

浙公网安备 33010602011771号