/*
* ome.formats.ModelException
*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2008 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*------------------------------------------------------------------------------
*/
package ome.formats.model;
import omero.model.IObject;
/**
* Exception thrown when there is an object instantiation error or error
* processing the model.
*
* @author Chris Allan <callan at blackcat dot ca>
*/
public class ModelException extends RuntimeException {
private static final long serialVersionUID = 4158130517527782400L;
/** The class that was used in a failed instantiation. */
private Class<? extends IObject> failureClass;
/**
* Default constructor.
* @param message Error message.
*/
public ModelException(String message) {
super(message);
}
/**
* Default constructor.
* @param message Error message.
* @param klass Failed instantiation class.
* @param exception Upstream exception.
*/
public ModelException(
String message, Class<? extends IObject> klass, Exception exception) {
super(message, exception);
this.failureClass = klass;
}
/**
* Returns the class that was used during a failed instantiation.
* @return See above.
*/
public Class<? extends IObject> getFailureClass() {
return failureClass;
}
@Override
public String toString() {
if (failureClass == null) {
return getMessage();
}
return getMessage() + " for " + failureClass;
}
}