Method parses the RSBException message and resolves the causes and messagen and use those to reconstruct the exception chain.

@param rsbException the origin RSBException

@return the reconstruced excetion cause chain.
979045
public static Exception resolveRSBException(final RSBException rsbException) {
        Exception exception = null;

        // build stacktrace array where each line is stored as entry. entry is extract each line stacktrace into arr
        final String[] stacktrace = ("Caused by: " + rsbException.getMessage()).split("\n");

        // iterate in reverse order to build exception chain.
        for (int i = stacktrace.length - 1; i >= 0; i--) {
            try {
                // only parse cause lines containing the exception class and message.
                if (stacktrace[i].startsWith("Caused by:")) {
                    final String[] causes = stacktrace[i].split(":");
                    final String exceptionClassName = causes[1].substring(1);

                    // System.out.println("parse: " + stacktrace[i]);
                    // System.out.println("match: " + causes.length);

                    final String message = causes.length <= 2 ? "" : stacktrace[i].substring(stacktrace[i].lastIndexOf(exceptionClassName) + exceptionClassName.length() + 2).trim();

                    // detect exception class
                    final Class<Exception> exceptionClass;
                    try {
                        exceptionClass = (Class<Exception>) Class.forName(exceptionClassName);

                        // build exception
                        try {
                            // try default constructor
                            exception = exceptionClass.getConstructor(String.class, Throwable.class).newInstance(message, exception);
                        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassCastException ex) {
                            try {
                                // try to handle missing fields
                                if (exception == null && message.isEmpty()) {
                                    exception = exceptionClass.getConstructor().newInstance();
                                } else if (exception == null && !message.isEmpty()) {
                                    exception = exceptionClass.getConstructor(String.class).newInstance(message);
                                } else if (exception != null && message.isEmpty()) {
                                    exception = exceptionClass.getConstructor(Throwable.class).newInstance(exception);
                                } else {
                                    throw ex;
                                }
                            } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException exx) {
                                throw new CouldNotPerformException("No compatible constructor found!", exx);
                            }
                        }
                        //System.out.println("create "+ exception.getClass().getSimpleName() + ":" + exception.getMessage());
                    } catch (ClassNotFoundException | ClassCastException | CouldNotPerformException ex) {
                        ExceptionPrinter.printHistory(new CouldNotPerformException("Exception[" + exceptionClassName + "] could not be recovered because no compatible Constructor(String, Throwable) was available!", ex), LOGGER, LogLevel.WARN);

                        // apply fallback solution
                        exception = new CouldNotPerformException(message, exception);
                    }
                }
            } catch (IndexOutOfBoundsException | NullPointerException ex) {
                ExceptionPrinter.printHistory(new CouldNotPerformException("Could not extract exception cause or message out of Line[" + stacktrace[i] + "]!", ex), LOGGER, LogLevel.WARN);
            }
        }
        return exception;
    }
437333
private J4pException mapException(Exception pException) throws J4pException {
        if (pException instanceof ConnectException) {
            return new J4pConnectException(
                    "Cannot connect to " + requestHandler.getJ4pServerUrl() + ": " + pException.getMessage(),
                    (ConnectException) pException);
        } else if (pException instanceof ConnectTimeoutException) {
            return new J4pTimeoutException(
                    "Read timeout while request " + requestHandler.getJ4pServerUrl() + ": " + pException.getMessage(),
                    (ConnectTimeoutException) pException);
        } else if (pException instanceof IOException) {
            return new J4pException("IO-Error while contacting the server: " + pException,pException);
        } else if (pException instanceof URISyntaxException) {
            URISyntaxException sExp = (URISyntaxException) pException;
            return new J4pException("Invalid URI " + sExp.getInput() + ": " + sExp.getReason(),pException);
        } else {
            return new J4pException("Exception " + pException,pException);
        }
    }
109116
public static DecodingException createDecodingException(
			final ErrorKeys errorId, final String message, final Exception e)
	{

		return new DecodingException(errorId.toString() + ":\r\n" + message, e);
	}
172997
public BackendSecuritySpec parseBeSecurity()
            throws BackendSecurityParserException {

        try {
            BackendSecurityDeserializer bsd =
                    new BackendSecurityDeserializer(m_encoding, m_validate);
            return bsd.deserialize(m_beSecurityPath);

        } catch (Throwable th) {
            throw new BackendSecurityParserException("[DefaultBackendSecurity] "
                    + "An error has occured in parsing the backend security "
                    + "configuration file located at \""
                    + m_beSecurityPath
                    + "\". "
                    + "The underlying error was a "
                    + th.getClass().getName()
                    + "The message was \""
                    + th.getMessage() + "\".");
        }
    }
801813
public ErrorPage getErrorPageByExceptionType(Throwable rootException) {
        // Begin 256281
        // Check for a perfect match first
        String exceptionName = rootException.getClass().getName();
        Object obj = exceptionErrorPages.get(exceptionName);
        if (obj != null)
            return (ErrorPage) obj;
        // Check to see if its a child of another exception type in the list
        Iterator i = exceptionErrorPages.values().iterator();
        ErrorPage curEP = null;
        ClassLoader warClassLoader = getWebApp().getClassLoader();
        while (i.hasNext()) {
            ErrorPage ep = (ErrorPage) i.next();
            // Class exceptionClass = ep.getException();
            Class exceptionClass = ep.getException(warClassLoader);
            if (exceptionClass != null && exceptionClass.isInstance(rootException)) {
                if (curEP == null)
                    curEP = ep;
                // else if
                // (curEP.getException().isAssignableFrom(exceptionClass))
                // //PK52168
                else if (curEP.getException(warClassLoader).isAssignableFrom(exceptionClass)) // PK52168
                    curEP = ep;
            }
        }
        return curEP;
        // End 256281
    }
44664
public RuntimeException traceError( RuntimeException cause ) {
        getLogger().log( Level.SEVERE, "Error during deserialization", cause );
        if ( wrapExceptions ) {
            return new JsonDeserializationException( cause );
        } else {
            return cause;
        }
    }
802199
public void setMessageException(Throwable ex)
    {
        String strErrorMessage = ex.getMessage();
        BaseMessage message = this.getMessage();
        if ((message != null) && (message.getMessageHeader() instanceof TrxMessageHeader))
            ((TrxMessageHeader)message.getMessageHeader()).put(TrxMessageHeader.MESSAGE_ERROR, strErrorMessage);
        else
            ex.printStackTrace();
    }
1005438
public static String formatException(final Exception e) {
    final StringBuilder sb = new StringBuilder();
    Throwable t = e;
    while (t != null) {
      sb.append(t.getMessage()).append("\n");
      t = t.getCause();
    }
    return sb.toString();
  }
183806
public boolean checkResponseForException() {
    if (!finished && rsp != null) {
      Exception e;
      if ((e = rsp.getException()) != null) {
        setError(e.getMessage());
        setFinished();
        return true;
      }
    }
    return false;
  }
559097
static AtsdServerException fromResponse(final Response response) {
        final int status = response.getStatus();
        try {
            final ServerError serverError = response.readEntity(ServerError.class);
            final String message = AtsdServerMessageFactory.from(serverError);
            return new AtsdServerException(message, status);
        } catch (ProcessingException e) {
            throw new IllegalArgumentException("Failed to extract server error", e);
        }
    }
1036751
private Response make() throws IOException {
        if (this.transformed.isEmpty()) {
            this.transformed.add(
                new RsWithBody(
                    this.origin,
                    RsPrettyJson.transform(this.origin.body())
                )
            );
        }
        return this.transformed.get(0);
    }
615590
protected static Throwable newDecoderException() {

        try {
            return DECODER_EXCEPTION.newInstance();
        } catch (final InstantiationException ie) {
            throw new RuntimeException(ie);
        } catch (final IllegalAccessException iae) {
            throw new RuntimeException(iae);
        }
    }
363505
def unwrap_causes(cause)
      causes, c, i = [], cause, 0

      while c && i < MAX_EXCEPTION_CAUSES
        causes << {
          class: c.class.name,
          message: c.message,
          backtrace: parse_backtrace(c.backtrace || caller)
        }
        i += 1
        c = exception_cause(c)
      end

      causes
    end
126446
public static Object parseWithException(String s) throws ParseException {
		return new JSONParser(DEFAULT_PERMISSIVE_MODE).parse(s, defaultReader.DEFAULT);
	}
719639
@Override
    public void handleException(HttpServletRequest req, HttpServletResponse rsp, Throwable wse) throws ServletException, IOException, ClassCastException {
        WebReply reply = ((WebSecurityCollaboratorException) (wse)).getWebReply();
        int sc = reply.getStatusCode();

        // Throw an exception if an error
        if (sc == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) {
            String method = null;
            if (req != null) {
                method = req.getMethod();
            }
            String url = getRequestURL(req);

            final ServletException ex = new ServletException(TraceNLS.getFormattedMessage(
                                                                                          this.getClass(),
                                                                                          TraceConstants.MESSAGE_BUNDLE,
                                                                                          "SEC_WEB_INTERNAL_SERVER_ERROR",
                                                                                          new Object[] { method, url },
                                                                                          "CWWKS9115E: The server encountered an unexpected condition which prevented it from fulfilling the request of method {0} for URL {1}. Review the server logs for more information."), wse);
            throw ex;
        }
        reply.writeResponse(rsp);
    }
397750
public Throwable getOriginalException() {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "getOriginalException");
        if (tc.isEntryEnabled())
            Tr.exit(tc, "getOriginalException", _originalException);
        return _originalException;
    }
25883
protected static StringBuilder handleExceptionStart(Exception e) {
        LOG.warning(ExceptionUtils.getStackTrace(e));
        StringBuilder sb = new StringBuilder();
        if (e.getMessage() != null) {
            sb.append(e.getMessage()).append(". ");
        }
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            sb.append(e.getCause().getMessage()).append(". ");
        }
        return sb;
    }