Package org.apache.velocity.exception

Examples of org.apache.velocity.exception.TemplateInitException


                /**
                 * correct the line/column number if an exception is caught
                 */
                catch (TemplateInitException die)
                {
                    throw new TemplateInitException(die.getMessage(),
                            (ParseException) die.getWrappedThrowable(),
                            die.getTemplateName(),
                            die.getColumnNumber() + getColumn(),
                            die.getLineNumber() + getLine());
                }
View Full Code Here


            {
                /**
                 *  indicate col/line assuming it starts at 0 - this will be
                 *  corrected one call up
                 */
                throw new TemplateInitException(errormsg,
                        context.getCurrentTemplateName(),
                        0,
                        0);
            }
            else
View Full Code Here

            /**
             * correct the line/column number if an exception is caught
             */
            catch (TemplateInitException die)
            {
                throw new TemplateInitException(die.getMessage(),
                        (ParseException) die.getWrappedThrowable(),
                        die.getTemplateName(),
                        die.getColumnNumber() + getColumn(),
                        die.getLineNumber() + getLine());
            }
View Full Code Here

                nodeTree  = rsvc.parse(br, (context != null) ?
                        context.getCurrentTemplateName() : "StringLiteral", false);
            }
            catch (ParseException e)
            {
                throw new TemplateInitException("Problem parsing String literal.",
                        e,
                        (context != null) ? context.getCurrentTemplateName() : "StringLiteral",
                        getColumn(),
                        getLine() );
            }
View Full Code Here

            }
            catch (ParseException e)
            {
                String msg = "Failed to parse String literal at "+
                    Log.formatFileString(templateName, getLine(), getColumn());
                throw new TemplateInitException(msg, e, templateName, getColumn(), getLine());
            }

            adjTokenLineNums(nodeTree);
           
            /*
 
View Full Code Here

             
                if (strictRef// If strict, throw now
                {
                    /* indicate col/line assuming it starts at 0
                     * this will be corrected one call up  */
                    throw new TemplateInitException(badArgsErrorMsg,
                        context.getCurrentTemplateName(), 0, 0);
                }
            }
        }              
    }
View Full Code Here

                    + Log.formatFileString(node), new Info(node));
            }

            if (badArgsErrorMsg != null)
            {
                throw new TemplateInitException(badArgsErrorMsg,
                  context.getCurrentTemplateName(), node.getColumn(), node.getLine());
            }

            try
            {
View Full Code Here

            if (strictArguments)
            {
                /**
                 * indicate col/line assuming it starts at 0 - this will be corrected one call up
                 */
                throw new TemplateInitException(buildErrorMsg(node, i),
                    context.getCurrentTemplateName(), 0, 0);
            }
            else if (rsvc.getLog().isDebugEnabled())
            {
                rsvc.getLog().debug(buildErrorMsg(node, i));
View Full Code Here

                    {
                        directive.init( rsvc, context, this );
                    }
                    catch (TemplateInitException die)
                    {
                        throw new TemplateInitException(die.getMessage(),
                            (ParseException) die.getWrappedThrowable(),
                            die.getTemplateName(),
                            die.getColumnNumber() + getColumn(),
                            die.getLineNumber() + getLine());
                    }
                    isDirective = true;
                }
                else
                {
                    // this is a fake block macro call without a body. e.g. #@foo
                    // just render as it is
                    isDirective = false;
                }
            }
            else
            {
                /**
                 * Create a new RuntimeMacro
                 */
                directive = new RuntimeMacro(directiveName);
                directive.setLocation(getLine(), getColumn(), getTemplateName());
       
                /**
                 * Initialize it
                 */
                try
                {
                    directive.init( rsvc, context, this );
                }
   
                /**
                 * correct the line/column number if an exception is caught
                 */
                catch (TemplateInitException die)
                {
                    throw new TemplateInitException(die.getMessage(),
                            (ParseException) die.getWrappedThrowable(),
                            die.getTemplateName(),
                            die.getColumnNumber() + getColumn(),
                            die.getLineNumber() + getLine());
                }
View Full Code Here

         */ 
       
        int argCount = node.jjtGetNumChildren();
        if (argCount == 0)
        {
            throw new TemplateInitException(
                    "#" + getName() + "() requires exactly one argument",
                    context.getCurrentTemplateName(),
                    node.getColumn(),
                    node.getLine());           
        }
        if (argCount > 1)
        {
            /*
             * use line/col of second argument
             */
           
            throw new TemplateInitException(
                    "#" + getName() + "() requires exactly one argument",
                    context.getCurrentTemplateName(),
                    node.jjtGetChild(1).getColumn(),
                    node.jjtGetChild(1).getLine());
        }
       
        Node childNode = node.jjtGetChild(0);
        if ( childNode.getType() !=  ParserTreeConstants.JJTSTRINGLITERAL &&
             childNode.getType() !=  ParserTreeConstants.JJTREFERENCE )
        {
           throw new TemplateInitException(
                   "#" + getName() + "()  argument must be a string literal or reference",
                   context.getCurrentTemplateName(),
                   childNode.getColumn(),
                   childNode.getLine());
        }
View Full Code Here

TOP

Related Classes of org.apache.velocity.exception.TemplateInitException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.