欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Java如何自定義異常打印非堆棧信息詳解-創(chuàng)新互聯(lián)

前言

創(chuàng)新互聯(lián)專注于企業(yè)成都營銷網(wǎng)站建設(shè)、網(wǎng)站重做改版、平橋網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、html5成都商城網(wǎng)站開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為平橋等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

在學(xué)習(xí)Java的過程中,想必大家都一定學(xué)習(xí)過異常這個(gè)篇章,異常的基本特性和使用這里就不再多講了。什么是異常?我不知道大家都是怎么去理解的,我的理解很簡單,那就是不正常的情況,比如我現(xiàn)在是個(gè)男的,但是我卻有著女人所獨(dú)有的東西,在我看來這尼瑪肯定是種異常,簡直不能忍。想必大家都能夠理解看懂,并正確使用。

但是,光學(xué)會基本異常處理和使用不夠的,在工作中出現(xiàn)異常并不可怕,有時(shí)候是需要使用異常來驅(qū)動業(yè)務(wù)的處理,例如: 在使用唯一約束的數(shù)據(jù)庫的時(shí)候,如果插入一條重復(fù)的數(shù)據(jù),那么可以通過捕獲唯一約束異常DuplicateKeyException來進(jìn)行處理,這個(gè)時(shí)候,在server層中就可以向調(diào)用層拋出對應(yīng)的狀態(tài),上層根據(jù)對應(yīng)的狀態(tài)再進(jìn)行處理,所以有時(shí)候異常對業(yè)務(wù)來說,是一個(gè)驅(qū)動方式。

有的捕獲異常之后會將異常進(jìn)行輸出,不知道細(xì)心的同學(xué)有沒有注意到一點(diǎn),輸出的異常是什么東西呢?

下面來看一個(gè)常見的異常:

java.lang.ArithmeticException: / by zero
 at greenhouse.ExceptionTest.testException(ExceptionTest.java:16)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
 at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
 at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
 at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
 at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
 at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

文章標(biāo)題:Java如何自定義異常打印非堆棧信息詳解-創(chuàng)新互聯(lián)
分享鏈接:http://www.chinadenli.net/article38/docssp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計(jì)公司Google面包屑導(dǎo)航網(wǎng)站設(shè)計(jì)營銷型網(wǎng)站建設(shè)動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管