Author: wglass Date: Fri Sep 23 23:04:39 2005 New Revision: 291256 URL: http://svn.apache.org/viewcvs?rev=291256&view=rev Log: check to see if Velocity was initialized and give meaninful exception message if not. VELOCITY-374
Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Modified: jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=291256&r1=291255&r2=291256&view=diff ============================================================================== --- jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java (original) +++ jakarta/velocity/core/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Fri Sep 23 23:04:39 2005 @@ -936,6 +936,12 @@ public Template getTemplate(String name, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception { + if (resourceManager == null) + { + throw new IllegalStateException + (" Cannot retrieve template as Velocity was not initialized."); + } + return (Template) resourceManager.getResource(name, ResourceManager.RESOURCE_TEMPLATE, encoding); @@ -975,6 +981,12 @@ public ContentResource getContent(String name, String encoding) throws ResourceNotFoundException, ParseErrorException, Exception { + if (resourceManager == null) + { + throw new IllegalStateException + (" Cannot retrieve content as Velocity was not initialized."); + } + return (ContentResource) resourceManager.getResource(name, ResourceManager.RESOURCE_CONTENT, encoding); @@ -992,6 +1004,12 @@ */ public String getLoaderNameForResource(String resourceName) { + if (resourceManager == null) + { + throw new IllegalStateException + (" Cannot retrieve template information as Velocity was not initialized."); + } + return resourceManager.getLoaderNameForResource(resourceName); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]