
org.apache.continuum.utils.ContinuumUtils Maven / Gradle / Ivy
The newest version!
package org.apache.continuum.utils;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.PrintWriter;
import java.io.StringWriter;
/**
* @author Trygve Laugstøl
* @version $Id: ContinuumUtils.java 734441 2009-01-14 16:31:04Z ctan $
*/
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