package org.javarosa.xpath;

import org.javarosa.xpath.parser.XPathSyntaxException;

/**
 * An exception detailing a function call that was provided the incorrect
 * number of arguments.
 *
 * Created by wpride1 on 3/28/15.
 */
public class XPathArityException extends XPathSyntaxException {
    private int expectedArity;
    private int providedArity;
    private String funcName;
    private String errorMessage;

    public XPathArityException() {
    }

    /**
     * An exception detailing a function call that was provided the incorrect
     * number of arguments.
     *
     * @param funcName      name of function that was called with incorrect number
     *                      of arguments
     * @param expectedArity number of arguments expected for this function call
     * @param providedArity number of arguments provided for this function call
     */
    public XPathArityException(String funcName, int expectedArity, int providedArity) {
        super("The " + funcName +
                " function was provided the incorrect number of arguments:" + providedArity +
                ". It expected " + expectedArity + " arguments.");

        this.errorMessage = "The " + funcName +
                " function was provided the incorrect number of arguments:" + providedArity +
                ". It expected " + expectedArity + " arguments.";
        this.expectedArity = expectedArity;
        this.providedArity = providedArity;
        this.funcName = funcName;
    }

    /**
     * An exception detailing a function call that was provided the incorrect
     * number of arguments.
     *
     * @param funcName             name of function that was called with incorrect number
     *                             of arguments
     * @param expectedArityMessage message describing the expected arity logic
     *                             of the function in question
     * @param providedArity        number of arguments provided for this function call
     */
    public XPathArityException(String funcName, String expectedArityMessage, int providedArity) {
        super("The " + funcName +
                " function was provided the incorrect number of arguments:" + providedArity +
                ". It expected " + expectedArityMessage + ".");

        this.errorMessage = "The " + funcName +
                " function was provided the incorrect number of arguments:" + providedArity +
                ". It expected " + expectedArityMessage + ".";
        this.expectedArity = -1;
        this.providedArity = providedArity;
        this.funcName = funcName;
    }
}

@@ -964,32 +964,34 @@
      super(%22The 
+%5C%22
 %22 + funcName +%0A 
@@ -998,32 +998,34 @@
                %22
+%5C%22
  function was pr
@@ -1178,32 +1178,34 @@
 rMessage = %22The 
+%5C%22
 %22 + funcName +%0A 
@@ -1212,32 +1212,34 @@
                %22
+%5C%22
  function was pr
@@ -2103,24 +2103,26 @@
  super(%22The 
+%5C%22
 %22 + funcName
@@ -2133,32 +2133,34 @@
                %22
+%5C%22
  function was pr
@@ -2318,16 +2318,18 @@
  = %22The 
+%5C%22
 %22 + func
@@ -2352,16 +2352,18 @@
        %22
+%5C%22
  functio

add quotes around function name in error msg to prevent confusion