日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

public ServiceException() { super(); } public ServiceException(String message, Throwable cause,

發布時間:2023/12/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 public ServiceException() { super(); } public ServiceException(String message, Throwable cause, 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

凡操作失敗都應該拋出某種異常,為了便于管理自定義的異常,應該先創建這些異常的基類,在創建異常要生成【無參構造】方法,如下一樣:
快捷鍵是:
代碼區域->右鍵->source->GenerateConstructors from Supperclass…無參數構造方法alt+shift+s+c

//ServiceException.凡操作失敗都應該拋出某種異常,為了便于管理自定義的異常,應該先創建這些異常的基類 public class ServiceException extends RuntimeException {private static final long serialVersionUID = -2879099986352308425L;public ServiceException() {super();}public ServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);}public ServiceException(String message, Throwable cause) {super(message, cause);}public ServiceException(String message) {super(message);}public ServiceException(Throwable cause) {super(cause);} } //UsernameDuplicateException 本次“注冊”之前,需要先檢查用戶名是否已經被占用,如果已經被占用,則需要拋出“用戶名被占用”的異常 public class UsernameDuplicateException extends ServiceException {private static final long serialVersionUID = 3164055183124220212L;public UsernameDuplicateException() {super();}public UsernameDuplicateException(String message, Throwable cause, boolean enableSuppression,boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);}public UsernameDuplicateException(String message, Throwable cause) {super(message, cause);}public UsernameDuplicateException(String message) {super(message);}public UsernameDuplicateException(Throwable cause) {super(cause);} } //本次“注冊”之前,需要先檢查用戶名是否已經被占用,如果已經被占用,則需要拋出“用戶名被占用”的異常 public class InsertException extends ServiceException{/*** */private static final long serialVersionUID = 878421569126542322L;public InsertException() {super();}public InsertException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);}public InsertException(String message, Throwable cause) {super(message, cause);}public InsertException(String message) {super(message);}public InsertException(Throwable cause) {super(cause);} } public class UserNotFoundException extends ServiceException{/*** 此次執行修改之前,需要檢查用戶數據是否存在,及是否被標記為“已刪除”,則可能拋出UserNotFoundException;*/private static final long serialVersionUID = 129945205934194859L;public UserNotFoundException() {super();}public UserNotFoundException(String message, Throwable cause, boolean enableSuppression,boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);}public UserNotFoundException(String message, Throwable cause) {super(message, cause);}public UserNotFoundException(String message) {super(message);}public UserNotFoundException(Throwable cause) {super(cause);}} public class PasswordNotMatchException extends ServiceException{/*** 在執行修改之前,還會檢查原密碼是否正確,如果原密碼錯誤,則可能拋出PasswordNotMatchException;*/private static final long serialVersionUID = 7750209971477940813L;public PasswordNotMatchException() {super();}public PasswordNotMatchException(String message, Throwable cause, boolean enableSuppression,boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);}public PasswordNotMatchException(String message, Throwable cause) {super(message, cause);}public PasswordNotMatchException(String message) {super(message);}public PasswordNotMatchException(Throwable cause) {super(cause);} } public class UpdateException extends ServiceException{/*** 在執行修改時,執行的是Update類型的操作,則可能拋出UpdateException*/private static final long serialVersionUID = 6612586132242913331L;public UpdateException() {super();}public UpdateException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);}public UpdateException(String message, Throwable cause) {super(message, cause);}public UpdateException(String message) {super(message);}public UpdateException(Throwable cause) {super(cause);} }

總結

以上是生活随笔為你收集整理的public ServiceException() { super(); } public ServiceException(String message, Throwable cause,的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。