package com.lsx.base;
public class MyException extends Exception {
private int detail;
public MyException(int detail) {
this.detail = detail;
}
@Override
public String toString() {
return "MyException{" +
"detail=" + detail +
'}';
}
}
class TestDemo {
public static void test(int a) throws MyException {
System.out.println("传递的参数为:" + a);
if (a > 10) {
throw new MyException(a);
}
System.out.println("OK!");
}
public static void main(String[] args) {
try {
test(12);
} catch (MyException e) {
System.out.println("MyException==>" + e);
}
}
}