001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.exp;
020
021import lucee.runtime.PageContext;
022import lucee.runtime.PageSource;
023import lucee.runtime.config.Config;
024import lucee.runtime.dump.DumpData;
025import lucee.runtime.dump.DumpProperties;
026import lucee.runtime.engine.ThreadLocalPageContext;
027import lucee.runtime.err.ErrorPage;
028import lucee.runtime.type.Struct;
029
030/**
031 *
032 *
033 * To change the template for this generated type comment go to
034 * Window - Preferences - Java - Code Generation - Code and Comments
035 */
036public class PageRuntimeException extends RuntimeException implements IPageException,PageExceptionBox {
037        
038        private PageException pe;
039
040        
041        /**
042         * constructor of the class
043         * @param pe page exception to hold
044         */
045        public PageRuntimeException(PageException pe) {
046                super(pe.getMessage());
047                this.pe=pe;
048        }
049        
050        /**
051         * standart excption constructor
052         * @param message message of the exception
053         */
054        public PageRuntimeException(String message) {
055                super(message);
056                this.pe=new ApplicationException(message);
057        }
058        
059        /**
060         * standart excption constructor
061         * @param message message of the exception
062         * @param detail detailed information to the exception
063         */
064        public PageRuntimeException(String message,String detail) {
065                super(message);
066                this.pe=new ApplicationException(message,detail);
067        }
068
069        @Override
070        public String getDetail() {
071                return pe.getDetail();
072        }
073        
074        @Override
075        public String getErrorCode() {
076                return pe.getErrorCode();
077        }
078        
079        @Override
080        public String getExtendedInfo() {
081                return pe.getExtendedInfo();
082        }
083        
084        @Override
085        public CatchBlock getCatchBlock(Config config) {
086                return pe.getCatchBlock(config);
087        }
088        
089        @Override
090        public Struct getCatchBlock(PageContext pc) {
091                return pe.getCatchBlock(pc.getConfig());
092        }
093        
094        public Struct getCatchBlock() {
095                // TLPC
096                return pe.getCatchBlock(ThreadLocalPageContext.getConfig());
097        }
098        
099        @Override
100        public Struct getErrorBlock(PageContext pc,ErrorPage ep) {
101                return pe.getErrorBlock(pc,ep);
102        }
103        @Override
104        public void addContext(PageSource template, int line, int column,StackTraceElement ste) {
105                pe.addContext(template,line,column,ste);
106        }
107        
108        @Override
109        public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
110                return pe.toDumpData(pageContext, maxlevel,dp);
111        }
112
113        @Override
114        public PageException getPageException() {
115                return pe;
116        }
117
118        @Override
119        public void setDetail(String detail) {
120                         pe.setDetail(detail);
121        }
122
123        @Override
124        public void setErrorCode(String errorCode) {
125                         pe.setErrorCode(errorCode);            
126        }
127
128        @Override
129        public void setExtendedInfo(String extendedInfo) {
130                         pe.setExtendedInfo(extendedInfo);              
131        }
132        
133        @Override
134        public boolean typeEqual(String type) {
135                return  pe.typeEqual(type);
136        }
137        
138        @Override
139        public String getTypeAsString() {
140                return pe.getTypeAsString();
141        }
142
143        @Override
144        public String getCustomTypeAsString() {
145                return pe.getCustomTypeAsString();
146        }
147
148    @Override
149    public int getTracePointer() {
150        return pe.getTracePointer();
151    }
152
153    @Override
154    public void setTracePointer(int tracePointer) {
155        pe.setTracePointer(tracePointer);
156    }
157
158    @Override
159    public Struct getAdditional() {
160        return pe.getAddional();
161    }
162    public Struct getAddional() {
163        return pe.getAddional();
164    }
165
166    public String getStackTraceAsString() {
167        return pe.getStackTraceAsString();
168    }
169}