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