package zhangshe.json;

/**
 * Citation: Use the method in the following website as a referrence.
 * http://stackoverflow
 * .com/questions/1754315/how-to-create-our-own-exceptions-in-java
 * 
 * To throw an Exception
 * 
 * @author Shen Zhang
 * 
 */

@SuppressWarnings("serial")
public class JSONException
    extends Exception
{
  // +--------+----------------------------------------------------------
  // | Fields |
  // +--------+
  String msg = null;

  // +--------------+----------------------------------------------------------
  // | Constructors |
  // +--------------+
  /**
   * A bunch of JSONExceptions
   */
  public JSONException()
  {
    super();
  } // JSONException()

  public JSONException(String msg)
  {
    super(msg);
    this.msg = msg;
  } // JSONException(String)

  public JSONException(String msg, int index)
  {
    super(msg);
    this.msg = msg;
  } // JSONException(String)

  public JSONException(String str, String msg, int index)
  {
    //super(msg);
    System.out.println(str);
    System.err.format("%" + (1 + index) + "s", "^");
    System.err.println("\n" + msg);
  } // JSONException(String, String, int)

  public JSONException(String msg, Throwable cause)
  {
    super(msg, cause);
  } // JSONException(String, Throwable)

  public JSONException(Throwable cause)
  {
    super(cause);
  } // JSONException(Throwable)

} // class JSONException

@@ -945,27 +945,32 @@
 str, String 
-msg
+expected
 , int index)
@@ -1104,19 +1104,54 @@
 (%22%5Cn%22 + 
-msg
+%22Invalid input: Expecting %22 + expected
 );%0A  %7D /

Add a new exception