Introduction to Java Exception Handling

http://tutorials.jenkov.com/java-exception-handling/index.html

 

一个好的java网站

http://www.java-tips.org/java-se-tips/java.util.logging/how-to-log-an-exception.html

 

Exception handling is a very important yet often neglected aspect of writing robust software. When an error occurs in a Java program it usually results in an exception being thrown. How you throw, catch and handle these exception matters. There are several different ways to do so. Not all are equally efficient and fail safe.

This trail digs deeper into exception handling in Java. The trail covers various do's and dont's of Java exception handling. It also covers a few techniques for efficient and less error prone exception handling. Hopefully you can benefit from some of these texts.

Below follows a quick introduction to what you can learn in this Java exception handling trail.

 

Basic Java Exception Handling

The first 2 texts on Java exception handling covers the basics of Java's exception throwing and catching mechanism, and exception hierarchies. These texts are:

 

Checked vs. Unchecked Exceptions in Java

Java is one of the few languages to support both checked and unchecked exceptions. In the text Checked or Unchecked Exceptions? I discuss the difference between these two types of exceptions. I also end up recommending unchecked exceptions over checked exceptions.

 

General Java Exception Handling Advice

The middle 6 texts in this Java exception handling trail covers issues like "fail safe exception" handling, "where to log exceptions", advice on throwing exceptions during validation etc. In other words, various advice on what to remember when designing your application exception throwing and handling.

 

Advanced Exception Handling in Java

The two texts Exception Handling Templates and Exception Enrichment discusses two somewhat more advanced exception handling techniques that can clean up your code a bit. Exception templates moves all the "try-catch" code to one or more reusable exception handling templates. Exception enrichment rids you of having tons of different exceptions in your exception hierarchy. It also helps you avoid long exception stack traces, and get truly unique error codes for each error in your application.

 

Most Popular on Java Exception Handling

The most popular texts in this Java exception handling tutorial are the texts on Exception Handling Templates and Exception Enrichment.

 

Table of Contents for Java Exception Handling Tutorial

Below is a list of the texts this trail Java Exception Handling contains. The list is repeated at the top right of every page in the trail.

 

  Java Exception Handling
 
 Introduction to Java Exception Handling
 Basic Try Catch Finally
 Exception Hierarchies
 Checked or Unchecked Exceptions?
 Exception Wrapping
 Fail Safe Exception Handling
 Pluggable Exception Handlers
 Logging: Where to Log Exceptions?
 Validation: Throw Exceptions Early
 Validation: Throw Exception or Return False?
 Exception Handling Templates
 Exception Enrichment
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值