/* * The contents of this file are subject to the Mozilla Public License Version 1.1 * (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at . * * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT * WARRANTY OF ANY KIND, either express or implied. See the License for the specific * language governing rights and limitations under the License. * * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.dynamo.except; import java.text.MessageFormat; import java.util.*; import com.silverwrist.util.StringUtils; public class ScriptingException extends ExternalException { /*-------------------------------------------------------------------------------- * Static data members *-------------------------------------------------------------------------------- */ private static final String BUNDLE = "com.silverwrist.dynamo.except.DynamoExceptionMessages"; /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- */ private String m_source = null; private String m_language = null; /*-------------------------------------------------------------------------------- * Constructors *-------------------------------------------------------------------------------- */ public ScriptingException(Class caller, String bundle, String message_id) { super(caller,bundle,message_id); } // end constructor public ScriptingException(Class caller, String bundle, String message_id, Throwable inner) { super(caller,bundle,message_id,inner); } // end constructor public ScriptingException(String source, String language, Class caller, String bundle, String message_id) { super(caller,bundle,message_id); m_source = source; m_language = language; } // end constructor public ScriptingException(String source, String language, Class caller, String bundle, String message_id, Throwable inner) { super(caller,bundle,message_id,inner); m_source = source; m_language = language; } // end constructor /*-------------------------------------------------------------------------------- * Overrides from class DynamoRuntimeException *-------------------------------------------------------------------------------- */ /** * Creates a localized description of this exception. Subclasses may override this method in * order to produce a locale-specific message. For subclasses that do not override this method, * the default implementation returns the same result as getLocalizedMessage(). * * @param locale The locale to render the message in. * @return The localized description of this exception. */ public String getLocalizedMessage(Locale locale) { if ((m_source==null) || (m_language==null)) return super.getLocalizedMessage(locale); ResourceBundle b = ResourceBundle.getBundle(BUNDLE,locale,getClass().getClassLoader()); Object[] args = new Object[3]; args[0] = m_source; args[1] = m_language; args[2] = super.getLocalizedMessage(locale); return MessageFormat.format(b.getString("scriptingException"),args); } // end getLocalizedMessage /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- */ public final String getSource() { return m_source; } // end getSource public final String getLanguage() { return m_language; } // end getLanguage } // end class ScriptingException