<commit_before>/*
// $Id$
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2006-2006 <NAME>
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.xmla;

/**
 * ...
 *
 * @author jhyde
 * @version $Id$
 * @since Apr 12, 2006
 */
public class XmlaException extends RuntimeException {
    private final String code;
    private final String faultString;

    public XmlaException(String message,Throwable cause) {
        this(null, null, message, cause);
    }

    public XmlaException(String faultString, String code, String message,Throwable cause) {
        super(message, cause);
        this.code = code;
        this.faultString = faultString;
    }

    public String getCode() {
        return code;
    }

    public String getFaultString() {
        return faultString;
    }

    public static String formatFaultCode(XmlaException xex) {
        return xex.faultString;
    }

    public static String formatDetail(Object detail) {
        throw new UnsupportedOperationException();
    }

    public Object getDetail() {
        throw new UnsupportedOperationException();
    }

    public static Throwable getRootCause(Throwable t) {
        throw new UnsupportedOperationException();
    }

    public static String formatFaultCode(String serverFaultFc, String code) {
        throw new UnsupportedOperationException();
    }
}

// End XmlaException.java<commit_msg>MONDRIAN        XMLA Exception class used to generate SOAP fault body.<commit_after>/*
// $Id$
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2004-2005 TONBELLER AG
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.xmla;

import mondrian.olap.MondrianException;

/** 
 * An exception thrown while processing an XMLA request. The faultcode
 * corresponds to the SOAP Fault faultcode and the faultstring
 * to the SOAP Fault faultstring.
 * 
 * @author <a><NAME></a>
 * @version $Id$
 */
public class XmlaException extends MondrianException {

    public static String formatFaultCode(XmlaException xex) {
        return formatFaultCode(xex.getFaultCode(), xex.getCode());
    }
    public static String formatFaultCode(String faultCode, String code) {
        return formatFaultCode(XmlaConstants.SOAP_PREFIX, 
                faultCode, code);
    }
    public static String formatFaultCode(String nsPrefix, 
                String faultCode, String code) {
        return nsPrefix + 
            ':' + 
            faultCode +
            '.' + 
            code;
    }
    public static String formatDetail(String msg) {
        return XmlaConstants.FAULT_FS_PREFIX + msg;
    }

    public static Throwable getRootCause(Throwable throwable) {
        Throwable t = throwable;
        while (t.getCause() != null) {
            t = t.getCause();
        }
        return t;
    }

    private final String faultCode; 
    private final String code; 
    private final String faultString; 

    public XmlaException(
            String faultCode, 
            String code, 
            String faultString,
            Throwable cause) {
        super(faultString, cause);
        this.faultCode = faultCode;
        this.code = code;
        this.faultString = faultString;
    }

    public String getFaultCode() {
        return faultCode;
    }
    public String getCode() {
        return code;
    }
    public String getFaultString() {
        return faultString;
    }
    public String getDetail() {
        Throwable t = getCause();
        t = getRootCause(t);
        String detail = t.getMessage();
        return (detail != null)
            ? detail
            : t.getClass().getName();
    }
}

{'fraction_non_alphanumeric': 0.08823529411764706, 'fraction_numerical': 0.005530417295123178, 'mean_word_length': 2.4569939183318854, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927205', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1065, 'n_words': 338}