Here you can find the source of throwException(final Throwable t)
Parameter | Description |
---|---|
t | The exception. Ignored if <tt>null</tt>. |
Parameter | Description |
---|---|
SQLException | The exception. |
static final void throwException(final Throwable t) throws SQLException
//package com.java2s; /*// w w w.j a v a2 s . c o m * Copyright 2010 Attribyte, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and limitations under the License. * */ import java.sql.SQLException; public class Main { /** * Examine a <tt>Throwable</tt> to preserve <tt>RuntimeException</tt> and <tt>Error</tt>, otherwise throw a <tt>SQLException</tt>. * @param t The exception. Ignored if <tt>null</tt>. * @throws SQLException The exception. */ static final void throwException(final Throwable t) throws SQLException { throwException(t, null); } /** * Examine a <tt>Throwable</tt> to preserve <tt>RuntimeException</tt> and <tt>Error</tt>, otherwise throw a <tt>SQLException</tt>. * @param t The exception. Ignored if <tt>null</tt>. * @param message A message to be added to the <tt>SQLException</tt>. * @throws java.sql.SQLException The exception. */ static final void throwException(final Throwable t, final String message) throws SQLException { if (t != null) { if (t instanceof SQLException) { throw (SQLException) t; } else if (t instanceof Error) { throw (Error) t; } else if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { if (message != null) { throw new SQLException(message, t); } else { throw new SQLException(t); } } } } }