Catch exceptions caused by fetching with invalid indices
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* A collector that does not use reflection and can be used with GWT.
|
||||
@@ -58,6 +59,8 @@ public abstract class BasicCollector implements Mustache.Collector
|
||||
return ((List<?>)ctx).get(Integer.parseInt(name));
|
||||
} catch (NumberFormatException nfe) {
|
||||
return Template.NO_FETCHER_FOUND;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return Template.NO_FETCHER_FOUND;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -68,6 +71,8 @@ public abstract class BasicCollector implements Mustache.Collector
|
||||
return ((Object[])ctx)[Integer.parseInt(name)];
|
||||
} catch (NumberFormatException nfe) {
|
||||
return Template.NO_FETCHER_FOUND;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return Template.NO_FETCHER_FOUND;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -80,6 +85,8 @@ public abstract class BasicCollector implements Mustache.Collector
|
||||
return iter.next();
|
||||
} catch (NumberFormatException nfe) {
|
||||
return Template.NO_FETCHER_FOUND;
|
||||
} catch (NoSuchElementException e) {
|
||||
return Template.NO_FETCHER_FOUND;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user