| package com.guoba.exception; |
| |
| |
| |
| public class LiXuanException extends Exception{ |
| private int detail; |
| |
| public LiXuanException(int e){ |
| this.detail = e; |
| } |
| |
| @Override |
| public String toString() { |
| return "LiXuanException{" + |
| "detail=" + detail + |
| '}'; |
| } |
| } |
| package com.guoba.exception; |
| |
| public class test { |
| |
| static void test(int e)throws LiXuanException{ |
| System.out.println("传递的参数为"+e); |
| if (e>10){ |
| throw new LiXuanException(e); |
| |
| } |
| System.out.println("ok"); |
| } |
| |
| public static void main(String[] args) { |
| try { |
| test(11); |
| } catch (LiXuanException e) { |
| System.out.println("LixuanException=>"+e); |
| } |
| } |
| } |