MYFACES-3226 move to Location aware exceptions
diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java b/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java
index 54b01b6..5b202c5 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java
@@ -70,6 +70,7 @@
 import org.apache.myfaces.component.visit.MyFacesVisitHints;
 import org.apache.myfaces.view.facelets.component.UIRepeat;
 import org.apache.myfaces.view.facelets.el.ContextAware;
+import org.apache.myfaces.view.facelets.LocationAware;
 
 /**
  * This class provides utility methods to generate the
@@ -587,24 +588,36 @@
     private static void _writeCause(Writer writer, Throwable ex) throws IOException
     {
         String msg = ex.getMessage();
-        String contextAwareLocation = null;
+        String locationString = null;
         if (ex instanceof ContextAware)
         {
             ContextAware caex = (ContextAware) ex;
-            contextAwareLocation = caex.getLocation().toString() + "    " +
+            locationString = caex.getLocation().toString() + "    " +
                                    caex.getQName() + "=\"" +
                                    caex.getExpressionString() + '"';
         }
+        else if (ex instanceof LocationAware)
+        {
+            LocationAware laex = (LocationAware) ex;
+            locationString = laex.getLocation().toString();
+        }
+
         while (ex.getCause() != null)
         {
             ex = ex.getCause();
             if (ex instanceof ContextAware)
             {
                 ContextAware caex = (ContextAware) ex;
-                contextAwareLocation = caex.getLocation().toString() + "    " +
+                locationString = caex.getLocation().toString() + "    " +
                         caex.getQName() + "=\"" +
                         caex.getExpressionString() + '"';
             }
+            else if (ex instanceof LocationAware)
+            {
+                LocationAware laex = (LocationAware) ex;
+                locationString = laex.getLocation().toString();
+            }
+            
             if (ex.getMessage() != null)
             {
                 msg = ex.getMessage();
@@ -623,10 +636,10 @@
         StackTraceElement stackTraceElement = ex.getStackTrace()[0];
         writer.write("<br/> at " + stackTraceElement.toString());
 
-        if (contextAwareLocation != null)
+        if (locationString != null)
         {
             writer.write("<br/> <br/>");
-            writer.write(contextAwareLocation);
+            writer.write(locationString);
             writer.write("<br/>");
         }
     }
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/el/LocationAware.java b/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAware.java
similarity index 96%
rename from impl/src/main/java/org/apache/myfaces/view/facelets/el/LocationAware.java
rename to impl/src/main/java/org/apache/myfaces/view/facelets/LocationAware.java
index c9864ad..3d6d9d6 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/el/LocationAware.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAware.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.view.facelets.el;
+package org.apache.myfaces.view.facelets;
 
 import javax.faces.view.Location;
 
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAwareFacesException.java b/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAwareFacesException.java
new file mode 100644
index 0000000..3d45559
--- /dev/null
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAwareFacesException.java
@@ -0,0 +1,84 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.myfaces.view.facelets;

+

+import javax.faces.FacesException;

+import javax.faces.component.UIComponent;

+import javax.faces.view.Location;

+

+public class LocationAwareFacesException extends FacesException implements LocationAware

+{

+    private Location location;

+    

+    public LocationAwareFacesException()

+    {

+        super();

+    }

+    

+    public LocationAwareFacesException(Location location)

+    {

+        super();

+        this.location = location;

+    }

+

+    public LocationAwareFacesException(Throwable cause)

+    {

+        super(cause);

+    }

+    

+    public LocationAwareFacesException(Throwable cause, Location location)

+    {

+        super(cause);

+        this.location = location;

+    }

+

+    public LocationAwareFacesException(String message)

+    {

+        super(message);

+    }

+

+    public LocationAwareFacesException(String message, Location location)

+    {

+        super(message);

+        this.location = location;

+    }

+    

+    public LocationAwareFacesException(String message, UIComponent component)

+    {

+        super(message);

+        this.location = (Location) component.getAttributes().get(UIComponent.VIEW_LOCATION_KEY);

+    }

+    

+    public LocationAwareFacesException(String message, Throwable cause)

+    {

+        super(message, cause);

+    }

+    

+    public LocationAwareFacesException(String message, Throwable cause, Location location)

+    {

+        super(message, cause);

+        this.location = location;

+    }

+

+    @Override

+    public Location getLocation()

+    {

+        return location;

+    }

+}

diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java b/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
index fb48808..57d2277 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
@@ -61,6 +61,7 @@
 import org.apache.myfaces.util.lang.Assert;
 import org.apache.myfaces.util.SharedStringBuilder;
 import org.apache.myfaces.util.ExternalSpecifications;
+import org.apache.myfaces.view.facelets.LocationAwareFacesException;
 import org.apache.myfaces.view.facelets.ViewPoolProcessor;
 
 /**
@@ -930,13 +931,13 @@
         {
             if (step > 0 && (end < begin))
             {
-                throw new FacesException("on empty models, end cannot be less than begin " +
-                        "when the step is positive");
+                throw new LocationAwareFacesException("on empty models, end cannot be less than begin " +
+                        "when the step is positive", this);
             }
             else if (step < 0 && (end > begin))
             {
-                throw new FacesException("on empty models, end cannot be greater than begin " +
-                        "when the step is negative");
+                throw new LocationAwareFacesException("on empty models, end cannot be greater than begin " +
+                        "when the step is negative", this);
             }
             setStep(step);
         }
@@ -944,44 +945,37 @@
         {
             if (size < 0)
             {
-                throw new FacesException("iteration size cannot be less " +
-                        "than zero");
+                throw new LocationAwareFacesException("iteration size cannot be less than zero", this);
             }
             else if (!sizeIsEnd && (begin == -1) && (offset + size) > end)
             {
-                throw new FacesException("iteration size cannot be greater " +
-                        "than collection size");
+                throw new LocationAwareFacesException("iteration size cannot be greater than collection size", this);
             }
             else if (!sizeIsEnd && (begin == -1) && (offset + size) > count)
             {
-                throw new FacesException("iteration size cannot be greater " +
-                        "than collection size");
+                throw new LocationAwareFacesException("iteration size cannot be greater than collection size", this);
             }
             else if (!sizeIsEnd && (begin >= 0) && (begin + size) > end+1)
             {
-                throw new FacesException("iteration size cannot be greater " +
-                        "than collection size");
+                throw new LocationAwareFacesException("iteration size cannot be greater than collection size", this);
             }
             else if(!sizeIsEnd && (begin >= 0) && (end+1 > count))
             {
-                throw new FacesException("end cannot be greater " +
-                        "than collection size");
+                throw new LocationAwareFacesException("end cannot be greater than collection size", this);
             }
             else if(!sizeIsEnd && (begin >= 0) && (begin > count))
             {
-                throw new FacesException("begin cannot be greater " +
-                        "than collection size");
+                throw new LocationAwareFacesException("begin cannot be greater than collection size", this);
             }
         }
-        if (!_emptyModel && (begin >= 0) && (begin > end))
+
+        if (begin >= 0 && begin > end)
         {
-            throw new FacesException("begin cannot be greater " +
-                    "than end");
+            throw new LocationAwareFacesException("begin cannot be greater than end", this);
         }
-        if (!_emptyModel && (size > -1) && (offset > end))
+        if (size > -1 && offset > end)
         {
-            throw new FacesException("iteration offset cannot be greater " +
-                    "than collection size");
+            throw new LocationAwareFacesException("iteration offset cannot be greater than collection size", this);
         }
 
         if (!_emptyModel && step == -1)
@@ -991,14 +985,12 @@
 
         if (!_emptyModel && step < 0)
         {
-            throw new FacesException("iteration step size cannot be less " +
-                    "than zero");
+            throw new LocationAwareFacesException("iteration step size cannot be less than zero", this);
         }
 
         else if (step == 0)
         {
-            throw new FacesException("iteration step size cannot be equal " +
-                    "to zero");
+            throw new LocationAwareFacesException("iteration step size cannot be equal to zero", this);
         }
 
         _end = end;
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/el/ContextAware.java b/impl/src/main/java/org/apache/myfaces/view/facelets/el/ContextAware.java
index 2d00153..3aca3a3 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/el/ContextAware.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/el/ContextAware.java
@@ -18,6 +18,8 @@
  */
 package org.apache.myfaces.view.facelets.el;
 
+import org.apache.myfaces.view.facelets.LocationAware;
+
 
 /**
  * Identification inferface for types that know about {@link javax.faces.view.Location}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/el/LocationMethodExpression.java b/impl/src/main/java/org/apache/myfaces/view/facelets/el/LocationMethodExpression.java
index 34f9b37..28d793d 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/el/LocationMethodExpression.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/el/LocationMethodExpression.java
@@ -18,6 +18,7 @@
  */
 package org.apache.myfaces.view.facelets.el;
 
+import org.apache.myfaces.view.facelets.LocationAware;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java
index 26d853b..f12c750 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java
@@ -66,7 +66,7 @@
         
         if (targetsArray.length > 0)
         {
-            List<UIComponent> targetsList = new ArrayList<UIComponent>(targetsArray.length);
+            List<UIComponent> targetsList = new ArrayList<>(targetsArray.length);
             for (String target : targetsArray)
             {
                 UIComponent innerComponent = topLevelComponent.findComponent(target);
@@ -103,7 +103,7 @@
                     if (innerComponent instanceof ClientBehaviorHolder ||
                         UIComponent.isCompositeComponent(innerComponent))
                     {
-                        List<UIComponent> targetsList = new ArrayList<UIComponent>(1);
+                        List<UIComponent> targetsList = new ArrayList<>(1);
                         targetsList.add(
                                 new ClientBehaviorRedirectEventComponentWrapper(innerComponent, getName(), getEvent()));
                         return targetsList;