/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */

package com.liferay.portal.configuration.persistence.listener;

import java.io.IOException;

import java.util.Dictionary;

/**
 * @author Drew Brokke
 */
public class ConfigurationModelListenerException extends IOException {

	public ConfigurationModelListenerException(
		Exception exception, Class<?> configurationClass,
		Class<?> listenerClass, Dictionary properties) {

		super(
			String.format(
				"The listener %s was unable to save configuration %s. Caused by: %s",
				listenerClass.getName(), configurationClass.getName(), exception.getMessage()),
			exception);

		this.causeMessage = exception.getMessage();
		this.configurationClass = configurationClass;
		this.listenerClass = listenerClass;
		this.properties = properties;
	}
	
	public ConfigurationModelListenerException(
			String causeMessage, Class<?> configurationClass,
			Class<?> listenerClass, Dictionary properties) {

			super(
				String.format(
					"The listener %s was unable to save configuration %s. Caused by: %s",
					listenerClass.getName(), configurationClass.getName(), causeMessage));

			this.causeMessage = causeMessage;
			this.configurationClass = configurationClass;
			this.listenerClass = listenerClass;
			this.properties = properties;
		}

	public final String causeMessage;
	public final Class<?> configurationClass;
	public final Class<?> listenerClass;
	public final Dictionary properties;

}