001    package railo.runtime.exp;
002    
003    import java.net.URL;
004    
005    import railo.runtime.config.Config;
006    import railo.runtime.type.util.KeyConstants;
007    
008    /**
009     * Exception class for the HTTP Handling
010     */
011    public final class HTTPException extends ApplicationException {
012    
013        private int statusCode;
014        private String statusText;
015            private URL url;
016    
017        
018        /**
019         * Constructor of the class
020         * @param message
021         * @param detail
022         * @param statusCode
023         */
024        public HTTPException(String message, String detail, int statusCode,String statusText,URL url) {
025            super(message,detail);
026            this.statusCode=statusCode;
027            this.statusText=statusText;
028            this.url=url;
029    
030            setAdditional(KeyConstants._statuscode, new Double(statusCode));
031                    setAdditional(KeyConstants._statustext, statusText);
032                    if(url!=null)setAdditional(KeyConstants._url, url.toExternalForm());
033        }
034    
035            /**
036         * @return Returns the statusCode.
037         */
038        public int getStatusCode() {
039            return statusCode;
040        }
041    
042            /**
043         * @return Returns the status text.
044         */
045        public String getStatusText() {
046            return statusText;
047        }
048        
049        public URL getURL(){
050            return url;
051        }
052    
053        @Override
054            public CatchBlock getCatchBlock(Config config) {
055                    CatchBlock sct = super.getCatchBlock(config);
056            sct.setEL("statusCode",statusCode+"");
057            sct.setEL("statusText",statusText);
058            if(url!=null)sct.setEL("url",url.toExternalForm());
059            return sct;
060        }
061    }