All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jaitools.jiffle.JiffleException Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2009-2011 Michael Bedward
 * 
 * This file is part of jai-tools.
 *
 * jai-tools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 *
 * jai-tools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public 
 * License along with jai-tools.  If not, see .
 * 
 */

package jaitools.jiffle;

import java.util.List;

/**
 * Exception class for errors encountered while compiling a script or
 * working with runtime objects.
 * 
 * @author Michael Bedward
 * @since 0.1
 * @version $Id: JiffleException.java 1639 2011-04-06 03:20:36Z michael.bedward $
 */
public class JiffleException extends Exception {

    /**
     * Create a new instance from an incoming exception.
     * 
     * @param thrwbl incoming exception
     */
    public JiffleException(Throwable thrwbl) {
        super(thrwbl);
    }

    /**
     * Creates a new instance with the given message.
     * 
     * @param msg error message
     */
    public JiffleException(String msg) {
        super(msg);
    }

    /**
     * Creates a new instance with the given list of messages.
     * 
     * @param errors list of error messages
     */
    public JiffleException(List errors) {
        super(listToString(errors));
    }

    /**
     * Creates a new instance from the given message and base object.
     * This is used by Jiffle to wrap Janino exceptions.
     * 
     * @param string error message
     * @param thrwbl base {@code Throwable} object
     */
    public JiffleException(String string, Throwable thrwbl) {
        super(string, thrwbl);
    }
    
    
    /**
     * Concatenates a list of messages, separating them with newline
     * characters.
     * 
     * @param msgList list of messages
     * 
     * @return the concatenated messages
     */
    private static String listToString(List msgList) {
        StringBuilder sb = new StringBuilder();
        for (String msg : msgList) {
            sb.append(msg).append("\n");
        }
        return sb.toString();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy