Package org.exist.xquery.ErrorCodes

Examples of org.exist.xquery.ErrorCodes.ErrorCode


    }

    @Override
    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
        // Define default values
        ErrorCode errorCode = DEFAULT_ERROR;
        String errorDesc = DEFAULT_DESCRIPTION;
        Sequence errorVal = Sequence.EMPTY_SEQUENCE;
        // Enter if one or more parameters are supplied
        if (args.length > 0) {
            // If there are 2 arguments or more supplied
            // use 2nd argument for error description
            if (args.length > 1) {
                errorDesc = args[1].getStringValue();
            }
            // If first argument is not empty, get qname from argument
            // and construct error code
            if (!args[0].isEmpty()) {
                final QName errorQName = ((QNameValue) args[0].itemAt(0)).getQName();
                String prefix = errorQName.getPrefix();
                if (prefix==null){
                    final String ns = errorQName.getNamespaceURI();
                    prefix = getContext().getPrefixForURI(ns);
                    errorQName.setPrefix(prefix);
                }
                errorCode = new ErrorCode(errorQName, errorDesc);
            }
            // If there is a third argument, use it.
            if (args.length == 3) {
                errorVal = args[2];
            }
        }
        logger.error(errorDesc + ": " + errorCode.toString());
        throw new XPathException(this, errorCode, errorDesc, errorVal);
    }
View Full Code Here


            final Sequence tryTargetSeq = tryTargetExpr.eval(contextSequence, contextItem);
            return tryTargetSeq;

        } catch (final Throwable throwable) {

            ErrorCode errorCode = null;
            XPathException xpe = null;

            // fn:error throws an XPathException
            if(throwable instanceof XPathException){
                // Get errorcode from nicely thrown xpathexception
                xpe = (XPathException)throwable;
                errorCode = xpe.getErrorCode();

                // if no errorcode is found, reconstruct by parsing the error text.
                if (errorCode == null) {
                    errorCode = extractErrorCode(xpe);
                } else if (errorCode == ErrorCodes.ERROR) {
                    errorCode = extractErrorCode(xpe);
                }

            } else {
                // Get errorcode from all other errors and exceptions
                errorCode = new JavaErrorCode(throwable);
            }

            // We need the qname in the end
            final QName errorCodeQname = errorCode.getErrorQName();

            // Exception in thrown, catch expression will be evaluated.
            // catchvars (CatchErrorCode (, CatchErrorDesc (, CatchErrorVal)?)? )
            // need to be retrieved as variables
            Sequence catchResultSeq = null;
View Full Code Here

        // if the 9th position has a ":" it is probably a custom error text
        if (':' == message.charAt(8)) {

            final String[] data = extractLocalName(xpe.getMessage());
            final ErrorCode errorCode = new ErrorCode(new QName(data[0], "err"), data[1]);
            errorCode.getErrorQName().setPrefix("err");
            LOG.debug("Parsed string '" + xpe.getMessage() + "' for Errorcode. "
                    + "Qname='" + data[0] + "' message='" + data[1] + "'");
            return errorCode;

        }
View Full Code Here

TOP

Related Classes of org.exist.xquery.ErrorCodes.ErrorCode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.