Here you can find the source of mergeException(List
public static SQLException mergeException(List<SQLException> exceptions)
//package com.java2s; //License from project: Apache License import java.sql.SQLException; import java.util.ArrayList; import java.util.List; public class Main { public static StackTraceElement split = new StackTraceElement("------- one sql exceptions-----", "", "", 0); public static SQLException mergeException(List<SQLException> exceptions) { // return new OneToManySQLExceptionsWrapper(exceptions); SQLException first = exceptions.get(0); List<StackTraceElement> stes = new ArrayList<StackTraceElement>(30 * exceptions.size()); // stes.addAll(Arrays.asList(first.getStackTrace())); boolean hasSplit = false; for (StackTraceElement ste : first.getStackTrace()) { stes.add(ste);//from w w w . ja v a2 s . c o m if (ste == split) { hasSplit = true; } } if (!hasSplit) { stes.add(split); } SQLException current = null; for (int i = 1, n = exceptions.size(); i < n; i++) { // newEx.setNextException(exceptions.get(i)); // current.setNextException(exceptions.get(i)); current = exceptions.get(i); // stes.addAll(Arrays.asList(exceptions.get(i).getStackTrace())); hasSplit = false; for (StackTraceElement ste : current.getStackTrace()) { stes.add(ste); if (ste == split) { hasSplit = true; } } if (!hasSplit) { stes.add(split); } } // newEx.getCause(); first.setStackTrace(stes.toArray(new StackTraceElement[stes.size()])); return first; } }