Here you can find the source of retrieveDetailException(Throwable throwable)
SQLException
containing detailed error information
Parameter | Description |
---|---|
throwable | a parameter |
public static SQLException retrieveDetailException(Throwable throwable)
//package com.java2s; /*********************************************************************************************************************** * Copyright (c) 2009 Sybase, Inc. All rights reserved. This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /*from ww w . j a v a2s . c o m*/ * Contributors: Sybase, Inc. - initial API and implementation **********************************************************************************************************************/ import java.sql.SQLException; public class Main { /** * Returns an instance of <code>SQLException</code> containing detailed error information * * @param throwable * @return */ public static SQLException retrieveDetailException(Throwable throwable) { String lineSep = System.getProperty("line.separator"); if (throwable != null) { StringBuffer msg = new StringBuffer(""); if (throwable.getLocalizedMessage() != null) { msg.append(throwable.getLocalizedMessage()); } else { msg.append(throwable.getMessage()); } if (throwable instanceof SQLException) { SQLException sqlEx = (SQLException) throwable; while (sqlEx.getNextException() != null) { sqlEx = sqlEx.getNextException(); if (sqlEx.getLocalizedMessage() != null) { msg.append("").append(lineSep).append(sqlEx.getLocalizedMessage()); } else { msg.append("").append(lineSep).append(sqlEx.getMessage()); } } } return new SQLException(msg.toString()); } return null; } }