org.apache.maven.continuum.utils.ContinuumUtils Maven / Gradle / Ivy
package org.apache.maven.continuum.utils;
/*
* Copyright 2005 The Apache Software Foundation.
*
* 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.io.StringWriter;
import java.io.PrintWriter;
/**
* @author Trygve Laugstøl
* @version $Id: ContinuumUtils.java 227315 2005-08-04 07:04:54Z brett $
*/
public class ContinuumUtils
{
public static final String EOL = System.getProperty( "line.separator" );
public static String throwableToString( Throwable error )
{
if ( error == null )
{
return "";
}
StringWriter writer = new StringWriter();
PrintWriter printer = new PrintWriter( writer );
error.printStackTrace( printer );
printer.flush();
return writer.getBuffer().toString();
}
public static String throwableMessagesToString( Throwable error )
{
if ( error == null )
{
return "";
}
StringBuffer buffer = new StringBuffer();
buffer.append( error.getMessage() );
error = error.getCause();
while ( error != null )
{
buffer.append( EOL );
buffer.append( error.getMessage() );
error = error.getCause();
}
return buffer.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy