for (int i = 0; i < childConfigs.length; i++) {
Configuration childConfig = childConfigs[i];
if (isChild(childConfig)) {
ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig);
if (builder instanceof HandleErrorsNodeBuilder) {
// Error handler : check type
HandleErrorsNode handler = (HandleErrorsNode)builder.buildNode(childConfig);
int status = handler.getStatusCode();
switch(status) {
case -1: // main handler (needs generator)
if (mainHandler != null) {
throw new ConfigurationException("Duplicate <handle-errors> at " + handler.getLocation());
} else if (error500Handler != null || error404Handler != null) {
throw new ConfigurationException("Cannot mix <handle-errors> with and without 'type' attribute at " +
handler.getLocation());
} else {
mainHandler = handler;
}
break;
case 404:
if (error404Handler != null) {
throw new ConfigurationException("Duplicate <handle-errors type='404' at " + handler.getLocation());
} else if(mainHandler != null) {
throw new ConfigurationException("Cannot mix <handle-errors> with and without 'type' attribute at " +
handler.getLocation());
} else {
error404Handler = handler;
}
break;
case 500:
if (error500Handler != null) {
throw new ConfigurationException("Duplicate <handle-errors type='500' at " + handler.getLocation());
} else if (mainHandler != null) {
throw new ConfigurationException("Cannot mix <handle-errors> with and without 'type' attribute at " +
handler.getLocation());
} else {
error500Handler = handler;
}
break;
default:
throw new ConfigurationException("Unknown handle-errors type (" + type + ") at " + handler.getLocation());
}
} else {
// Regular builder
children.add(builder.buildNode(childConfig));
}
}
}
node.setChildren(toNodeArray(children));
node.set404Handler(error404Handler);