集册 Java实例教程 返回指定异常的原因。

返回指定异常的原因。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

377
返回指定异常的原因。

/*

 * Copyright (c) 2015-2016 QuartzDesk.com.

 * Licensed under the MIT license (https://opensource.org/licenses/MIT).

 *///nowjava - 时  代  Java 提供

//package com.nowjava;


import java.sql.SQLException;


public class Main {

    /**

     * Returns the cause of the specified exception.

     *

     * @param t an exception.

     * @return the cause.

     */

    public static Throwable getCause(Throwable t) {

        // SQLException does not use "standard" cause chaining...grrr

        if (t instanceof SQLException) {

            return ((
展开阅读全文