博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【Java】自定义异常
阅读量:7238 次
发布时间:2019-06-29

本文共 1209 字,大约阅读时间需要 4 分钟。

 

package com.littlecat.cbb.exception;public class LittleCatException extends RuntimeException{    private static final long serialVersionUID = 1L;    private String errorCode;    public LittleCatException(String message)    {        super(message);    }    public LittleCatException(String errorCode, String message)    {        super(message);        this.errorCode = errorCode;    }    public LittleCatException(String errorCode, String message, Throwable cause)    {        super(message, cause);        this.errorCode = errorCode;    }    public LittleCatException(String message, Throwable cause)    {        super(message, cause);    }    public String getErrorCode()    {        return errorCode;    }    public void setErrorCode(String errorCode)    {        this.errorCode = errorCode;    }    //测试代码    public static void main(String[] args)    {        try        {            System.out.println(100 / 0);        }        catch (Exception e)        {            System.out.println(new LittleCatException("haha", e).getMessage());            throw new LittleCatException("haha", e);        }        throw new LittleCatException("haha");    }}

 

  

 

转载于:https://www.cnblogs.com/njlittlecat/p/9580693.html

你可能感兴趣的文章
虚拟磁盘工具vmkfstools的使用
查看>>
HP LaserJet Pro P1106网络打印机64位驱动安装
查看>>
【博客话题】我的linux戏曲
查看>>
继之前SCVMM WinRM问题后重新添加群集后Windows Azure Pack创建虚拟机失败
查看>>
第十六集被忽视的帧中继:原理及实验
查看>>
关于Ubuntu上Eclipse不显示手机设备
查看>>
iPhone的Push(推送通知)功能原理浅析
查看>>
Oracle 11g Release 1 (11.1) 游标——SQL 游标(隐式)
查看>>
欧拉函数
查看>>
用groovy写抓票程序
查看>>
设计资源推荐-20个漂亮的免费PSD图标格式
查看>>
学用MVC4做网站:序
查看>>
mysql kill操作
查看>>
Go Revel - i18n(国际化)
查看>>
MVC应用程序JsonResult()的练习
查看>>
VBS解析时候遇到时间
查看>>
Android应用公布的准备——渠道注冊与认证
查看>>
第四章 类加载机制
查看>>
字符和字符串
查看>>
使用Xamarin.Forms平台开发移动应用指南
查看>>