Here you can find the source of exceptionMessage(Throwable e)
public static String exceptionMessage(Throwable e)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Luigi Sgro. 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 * * Contributors:/* w w w . ja va 2 s . c o m*/ * Luigi Sgro - initial API and implementation ******************************************************************************/ public class Main { public static String exceptionMessage(Throwable e) { StringBuilder buffer = new StringBuilder(); buffer.append(extractMessage(e)); if (e.getCause() != null) { buffer.append(" [cause: ").append(extractMessage(e.getCause())).append("]"); } return buffer.toString(); } private static String extractMessage(Throwable e) { if (e.getMessage() != null) { return e.getMessage(); } else { return e.toString(); } } }