public static FileSystemException generate()

in commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java [58:86]


    public static FileSystemException generate(final DavException cause, final DavMethod davMethod) throws FileSystemException {
        String msg = cause.getMessage();
        if (cause.hasErrorCondition()) {
            try {
                final Element error = cause.toXml(DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument());
                if (DomUtil.matches(error, DavException.XML_ERROR, DavConstants.NAMESPACE) && DomUtil.hasChildElement(error, "exception", null)) {
                    final Element exc = DomUtil.getChildElement(error, "exception", null);
                    if (DomUtil.hasChildElement(exc, "message", null)) {
                        msg = DomUtil.getChildText(exc, "message", null);
                    }
                    if (DomUtil.hasChildElement(exc, "class", null)) {
                        final Class<?> cl = Class.forName(DomUtil.getChildText(exc, "class", null));
                        final Constructor<?> excConstr = cl.getConstructor(String.class);
                        final Object o = excConstr.newInstance(msg);
                        if (o instanceof FileSystemException) {
                            return (FileSystemException) o;
                        }
                        if (o instanceof Exception) {
                            return new FileSystemException(msg, (Exception) o);
                        }
                    }
                }
            } catch (final Exception e) {
                throw new FileSystemException(e);
            }
        }

        return new FileSystemException(msg);
    }