* <p>
* @return Property value
* <p>
- * @throws NullPointerException If given key is not found
+ * @throws NullPointerException If given key is NULL or not found
+ * @throws IllegalArgumentException If given key is empty
*/
- protected String getStringContextParameter (final String parameterKey) throws NullPointerException {
+ protected String getStringContextParameter (final String parameterKey) throws NullPointerException, IllegalArgumentException {
+ // Is the parameter valid?
+ if (null == parameterKey) {
+ // Throw NPE
+ throw new NullPointerException("parameterKey is null"); //NOI18N
+ } else if (parameterKey.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("parameterKey is empty"); //NOI18N
+ }
+
// Get context parameter
final String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey);
// Try to get context parameter
final String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
- // Is it set and true?
- final boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE;
-
// Return it
- return isEnabled;
+ return (Boolean.parseBoolean(contextParameter) == Boolean.TRUE);
}
/**
* A custom exception handler for nice output. This code is heavily based on
* this [1] example.
* <p>
- * 1: https://wmarkito.wordpress.com/2012/04/05/adding-global-exception-handling-using-jsf-2-x-exceptionhandler/
+ * 1:
+ * https://wmarkito.wordpress.com/2012/04/05/adding-global-exception-handling-using-jsf-2-x-exceptionhandler/
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
@Override
public void handle () throws FacesException {
-
+ // Get iterator. Please see below remove() call why a for(Foo foo:allFoos()) cannot work.
final Iterator<ExceptionQueuedEvent> iterator = this.getUnhandledExceptionQueuedEvents().iterator();
+ // Loop through all
while (iterator.hasNext()) {
final ExceptionQueuedEvent event = iterator.next();
final ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();