public ProblemBuilder fromRepositoryException()

in org.apache.sling.jaxrs/bundle/src/main/java/org/apache/sling/jaxrs/json/problem/ProblemBuilder.java [125:157]


    public ProblemBuilder fromRepositoryException(@NotNull RepositoryException exception) {
        if (exception instanceof InvalidQueryException
                || exception instanceof NoSuchNodeTypeException
                || exception instanceof ConstraintViolationException
                || exception instanceof InvalidLifecycleTransitionException
                || exception instanceof InvalidNodeTypeDefinitionException
                || exception instanceof InvalidSerializedDataException
                || exception instanceof ReferentialIntegrityException
                || exception instanceof UnsupportedRepositoryOperationException
                || exception instanceof ValueFormatException
                || exception instanceof VersionException) {
            withStatus(HttpServletResponse.SC_BAD_REQUEST);
        } else if (exception instanceof javax.jcr.LoginException) {
            withStatus(HttpServletResponse.SC_UNAUTHORIZED);
        } else if (exception instanceof javax.jcr.AccessDeniedException
                || exception instanceof javax.jcr.security.AccessControlException) {
            withStatus(HttpServletResponse.SC_FORBIDDEN);
        } else if ((exception instanceof ItemNotFoundException)
                || (exception instanceof PathNotFoundException)
                || exception instanceof NoSuchWorkspaceException) {
            withStatus(HttpServletResponse.SC_NOT_FOUND);
        } else if (exception instanceof ItemExistsException
                || exception instanceof InvalidItemStateException
                || exception instanceof LockException
                || exception instanceof MergeException
                || exception instanceof NodeTypeExistsException) {
            withStatus(HttpServletResponse.SC_CONFLICT);
        } else {
            withStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
        withDetail(exception.toString());
        return this;
    }