001    package railo.runtime.exp;
002    
003    import railo.commons.lang.StringUtil;
004    import railo.runtime.PageSource;
005    import railo.runtime.op.Caster;
006    import railo.transformer.util.CFMLString;
007    
008    
009    /**
010     * Template Exception Object
011     */
012    public class TemplateException extends PageExceptionImpl {
013    
014            /**
015             * @return the line
016             */
017            public int getLine() {
018                    return line;
019            }
020    
021            /**
022             * @return the pageSource
023             */
024            public PageSource getPageSource() {
025                    return pageSource;
026            }
027    
028            private int line;
029            private PageSource pageSource;
030    
031            /**
032             * constructor of the template exception
033             * @param message Exception Message
034             */
035            public TemplateException(String message) {
036                    super(message,"template");
037            }
038            
039            /**
040             * constructor of the template exception
041             * @param message Exception Message
042             * @param detail Detailed Exception Message
043             */
044            public TemplateException(String message, String detail) {
045                    super(message,"template");
046                    setDetail(detail);
047            }
048    
049            /**
050             * Constructor of the class
051             * @param cfml
052             * @param message
053             */
054            public TemplateException(PageSource ps, int line, int column,String message) {
055                    super(message,"template");
056                    //print.err(line+"+"+column);
057                    addContext(ps,line,column,null);
058                    this.line=line;
059                    this.pageSource=ps;
060            }
061    
062            /**
063             * Constructor of the class
064             * @param cfml
065             * @param message
066             */
067            public TemplateException(CFMLString cfml, String message) {
068                    this((PageSource)cfml.getSourceFile(),cfml.getLine(),cfml.getColumn(),message);
069            }
070            
071            /**
072             * Constructor of the class
073             * @param cfml
074             * @param message
075             * @param detail
076             */
077            public TemplateException(CFMLString cfml, String message, String detail) {
078                    this((PageSource)cfml.getSourceFile(),cfml.getLine(),cfml.getColumn(),message);
079                    setDetail(detail);
080            }
081    
082            /**
083             * Constructor of the class
084             * @param cfml
085             * @param e
086             */
087            public TemplateException(CFMLString cfml, Throwable e) {
088                    this(
089                                    cfml,
090                                    StringUtil.isEmpty(e.getMessage())?
091                                                    (Caster.toClassName(e)):
092                                                    e.getMessage());
093                    setStackTrace(e.getStackTrace());
094            }
095    }