Example usage for org.apache.commons.configuration2.ex ConfigurationException getCause

List of usage examples for org.apache.commons.configuration2.ex ConfigurationException getCause

Introduction

In this page you can find the example usage for org.apache.commons.configuration2.ex ConfigurationException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:Executable.LinkImputeR.java

private static void writeXML(XMLConfiguration xml, File output) throws OutputException {
    FileHandler handler = new FileHandler(xml);
    try {//from   w  w  w  .j  av a 2  s. c o m
        handler.save(output);
    } catch (ConfigurationException ex) {
        if (ex.getCause() instanceof IOException) {
            IOException tex = (IOException) ex.getCause();
            throw new OutputException("Problem writing XML file", tex);
        }
        throw new ProgrammerException(ex);
    }
}

From source file:Executable.Output.java

/**
 * Write the control file (for the final imputation step)
 * @param config The configuration to write
 * @throws OutputException If there is an IO problem
 *//* w ww  .j  a v  a2 s .com*/
public void writeControl(List<ImmutableNode> config) throws OutputException {
    BasicConfigurationBuilder<ExtendedXMLConfiguration> builder = new BasicConfigurationBuilder<>(
            ExtendedXMLConfiguration.class).configure(new Parameters().xml());

    ExtendedXMLConfiguration c;
    try {
        c = builder.getConfiguration();
    } catch (ConfigurationException ex) {
        throw new ProgrammerException(ex);
    }

    c.setRootElementName("linkimputepro");

    c.addNodes(null, config);

    FileHandler handler = new FileHandler(c);
    try {
        handler.save(control);
    } catch (ConfigurationException ex) {
        if (ex.getCause() instanceof IOException) {
            IOException tex = (IOException) ex.getCause();
            throw new OutputException("Problem writing imputation control file", tex);
        }
        throw new ProgrammerException(ex);
    }
}