/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 **/

package lucee.runtime.exp;

import lucee.runtime.config.Config;
import lucee.runtime.type.Collection;
import lucee.runtime.type.KeyImpl;

/**
 *
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class ExpressionException extends PageExceptionImpl {

	private static final Collection.Key ERR_NUMBER = KeyImpl.intern("ErrNumber");
	/**
	 * Class Constuctor
	 * @param message error message
	 */
	public ExpressionException(String message) {
		super(message,"expression"); 
	}

	/**
	 * Class Constuctor
	 * @param message error message
	 * @param detail detailed error message
	 */
	public ExpressionException(String message, String detail) {
		super(message,"expression");
		setDetail(detail);
	}
	
	@Override
	public CatchBlock getCatchBlock(Config config) {
		CatchBlock sct=super.getCatchBlock(config);
		sct.setEL(ERR_NUMBER,new Double(0));
		return sct;
	}
    /**
     * @param e
     * @return pageException
     */
    public static ExpressionException newInstance(Exception e) {
        if(e instanceof ExpressionException) return (ExpressionException) e;
        else if(e instanceof PageException) {
            PageException pe=(PageException)e;
	        ExpressionException ee = new ExpressionException(pe.getMessage());
	        ee.detail=pe.getDetail();
	        ee.setStackTrace(pe.getStackTrace());
	        return ee;
        }
        else  {
	        ExpressionException ee = new ExpressionException(e.getMessage());
	        ee.setStackTrace(e.getStackTrace());
	        return ee;
        }
    }
}
@@ -964,19 +964,16 @@
 nt go to
-%0A *
  Window%3E
@@ -1168,16 +1168,17 @@
 mber%22);%0A
+%0A
 %09/**%0A%09 *
@@ -1187,32 +1187,37 @@
 lass Constuctor%0A
+%09 * %0A
 %09 * @param messa
@@ -1210,32 +1210,47 @@
 * @param message
+%0A%09 *           
  error message%0A%09
@@ -1307,32 +1307,33 @@
 %09%09super(message,
+ 
 %22expression%22); %0A
@@ -1330,17 +1330,16 @@
 ssion%22);
- 
 %0A%09%7D%0A%0A%09/*
@@ -1357,24 +1357,29 @@
  Constuctor%0A
+%09 * %0A
 %09 * @param m
@@ -1384,16 +1384,31 @@
  message
+%0A%09 *           
  error m
@@ -1431,16 +1431,31 @@
 m detail
+%0A%09 *           
  detaile
@@ -1552,16 +1552,17 @@
 message,
+ 
 %22express
@@ -1592,17 +1592,16 @@
 il);%0A%09%7D%0A
-%09
 %0A%09@Overr
@@ -1670,17 +1670,19 @@
 lock sct
-=
+ = 
 super.ge
@@ -1725,16 +1725,17 @@
 _NUMBER,
+ 
 new Doub
@@ -1763,20 +1763,15 @@
 %0A%09%7D%0A
-    /**%0A    
+%0A%09/**%0A%09
  * @
@@ -1778,20 +1778,17 @@
 param e%0A
-    
+%09
  * @retu
@@ -1808,20 +1808,14 @@
 ion%0A
-     */%0A    
+%09 */%0A%09
 publ
@@ -1871,24 +1871,18 @@
 on e) %7B%0A
-        
+%09%09
 if(e ins
@@ -1909,17 +1909,20 @@
 ception)
- 
+%0A%09%09%09
 return (
@@ -1945,20 +1945,13 @@
 ion)
- 
 e;%0A
-        
+%09%09
 else
@@ -1984,28 +1984,19 @@
 tion) %7B%0A
-            
+%09%09%09
 PageExce
@@ -2003,17 +2003,19 @@
 ption pe
-=
+ = 
 (PageExc
@@ -2025,24 +2025,18 @@
 ion)e;%0A%09
-        
+%09%09
 Expressi
@@ -2095,24 +2095,18 @@
 ge());%0A%09
-        
+%09%09
 ee.detai
@@ -2106,17 +2106,19 @@
 e.detail
-=
+ = 
 pe.getDe
@@ -2122,32 +2122,26 @@
 tDetail();%0A%09
-        
+%09%09
 ee.setStackT
@@ -2163,32 +2163,26 @@
 kTrace());%0A%09
-        
+%09%09
 return ee;%0A 
@@ -2184,43 +2184,24 @@
 ee;%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 else 
- 
 %7B%0A%09
-        
+%09%09
 Expr
@@ -2263,24 +2263,18 @@
 ge());%0A%09
-        
+%09%09
 ee.setSt
@@ -2303,24 +2303,18 @@
 ce());%0A%09
-        
+%09%09
 return e
@@ -2320,21 +2320,12 @@
 ee;%0A
-        %7D%0A    
+%09%09%7D%0A%09
 %7D%0A%7D

format only