/** * {@inheritDoc} * * <p>If {@code cause} is a {@link ServiceException}, it is added to * the list of siblings so that the original exception appears when * using XML error output. */ @Override public Throwable initCause(Throwable cause) { super.initCause(cause); if (cause instanceof ServiceException) { addSibling((ServiceException) cause); } return this; }
/** * {@inheritDoc} * * <p>If {@code cause} is a {@link ServiceException}, it is added to * the list of siblings so that the original exception appears when * using XML error output. */ @Override public Throwable initCause(Throwable cause) { super.initCause(cause); if (cause instanceof ServiceException) { addSibling((ServiceException) cause); } return this; }
/** * Creates a new exception, registers it and sets {@code currentException}. * The first time this method is called, {@code currentException} is set * to {@code initialException}. * @return the new value of {@code currentException} */ private ServiceException nextException() { // nextException/currentException if (currentException == null) { currentException = initialException; return currentException; } try { // Create an exception of the same type as this one // and make it a sibling. currentException = initialException.getClass() .getConstructor(String.class).newInstance( initialException.getMessage()); initialException.addSibling(currentException); return currentException; } catch (InstantiationException ie) { throw new IllegalStateException(ie); } catch (NoSuchMethodException nsme) { throw new IllegalStateException(nsme); } catch (IllegalAccessException iae) { throw new IllegalStateException(iae); } catch (InvocationTargetException ite) { throw new IllegalStateException(ite); } }
/** * Creates a new exception, registers it and sets {@code currentException}. * The first time this method is called, {@code currentException} is set * to {@code initialException}. * @return the new value of {@code currentException} */ private ServiceException nextException() { // nextException/currentException if (currentException == null) { currentException = initialException; return currentException; } try { // Create an exception of the same type as this one // and make it a sibling. currentException = initialException.getClass() .getConstructor(String.class).newInstance( initialException.getMessage()); initialException.addSibling(currentException); return currentException; } catch (InstantiationException ie) { throw new IllegalStateException(ie); } catch (NoSuchMethodException nsme) { throw new IllegalStateException(nsme); } catch (IllegalAccessException iae) { throw new IllegalStateException(iae); } catch (InvocationTargetException ite) { throw new IllegalStateException(ite); } }
@Override public ElementHandler getChildHandler(String namespace, String localName, Attributes attrs) throws ParseException, IOException { if (Namespaces.g.equals(namespace)) { if ("error".equals(localName)) { if (currentException == null) { currentException = initialException; } else { try { // Create an exception of the same type as this one // and make it a sibling. currentException = initialException.getClass() .getConstructor(String.class).newInstance( initialException.getMessage()); initialException.addSibling(currentException); } catch (InstantiationException ie) { throw new IllegalStateException(ie); } catch (NoSuchMethodException nsme) { throw new IllegalStateException(nsme); } catch (IllegalAccessException iae) { throw new IllegalStateException(iae); } catch (InvocationTargetException ite) { throw new IllegalStateException(ite); } } return new ErrorHandler(); } } return super.getChildHandler(namespace, localName, attrs); }