public static int compute(int param){
int a=10;
int result=0;
try{
result=a/param;
}catch (Exception ex){
StackTraceElement stackTraceElement=ex.getStackTrace()[0];
String methodname=stackTraceElement.getMethodName();
int lineNumber=stackTraceElement.getLineNumber();
String className=stackTraceElement.getClassName();
String cause=ex.getMessage();
System.out.println(className+"类执行"+methodname+"方法报错,错误在"+lineNumber+"行。报错原因:"+cause);
}
return result;
}