/**
 * CompilerException.java
 * ---------------------------------
 * Copyright (c) 2016
 * RESOLVE Software Research Group
 * School of Computing
 * Clemson University
 * All rights reserved.
 * ---------------------------------
 * This file is subject to the terms and conditions defined in
 * file 'LICENSE.txt', which is part of this source code package.
 */
package edu.clemson.cs.rsrg.statushandling.exception;

import edu.clemson.cs.rsrg.parsing.data.Location;
import edu.clemson.cs.rsrg.parsing.data.PosSymbol;

/**
 * <p>The abstract parent class for all runtime exceptions the compiler.</p>
 *
 * @author Yu-Shan Sun
 * @version 2.0
 */
public abstract class CompilerException extends RuntimeException {

    // ===========================================================
    // Member Fields
    // ===========================================================

    /** <p>Location that caused the exception to be thrown</p> */
    private final Location myErrorLocation;

    // ==========================================================
    // Constructors
    // ==========================================================

    /**
     * <p>This constructor takes in a throwable cause and a message
     * that caused the exception to be thrown.</p>
     *
     * @param message Message to be displayed when the exception is thrown.
     * @param location Location where the exception originated from.
     */
    protected CompilerException(String message, Location location) {
        this(message, location, null);
    }

    /**
     * <p>This constructor takes in a message for the
     * symbol that caused the exception to be thrown.</p>
     *
     * @param message Message to be displayed when the exception is thrown.
     * @param symbol Offending symbol
     */
    protected CompilerException(String message, PosSymbol symbol) {
        this(message, symbol, null);
    }

    /**
     * <p>This constructor takes in a throwable cause and a message
     * that caused the exception to be thrown.</p>
     *
     * @param message Message to be displayed when the exception is thrown.
     * @param cause Cause of the exception.
     */
    protected CompilerException(String message, Throwable cause) {
        this(message, (Location) null, cause);
    }

    /**
     * <p>This constructor takes in a throwable cause and a message for the
     * symbol that caused the exception to be thrown.</p>
     *
     * @param message Message to be displayed when the exception is thrown.
     * @param symbol Offending symbol
     * @param cause Cause of the exception.
     */
    protected CompilerException(String message, PosSymbol symbol,
            Throwable cause) {
        this(message, symbol.getLocation(), cause);
    }

    /**
     * <p>This constructor takes in a throwable cause, a message and a location
     * that caused the exception to be thrown.</p>
     *
     * @param message Message to be displayed when the exception is thrown.
     * @param location Location where the exception originated from.
     * @param cause Cause of the exception.
     */
    protected CompilerException(String message, Location location,
            Throwable cause) {
        super(message, cause);
        myErrorLocation = location;
    }

    // ===========================================================
    // Public Methods
    // ===========================================================

    /**
     * <p>Return the location that caused this exception to be thrown.</p>
     *
     * @return A {@link Location} object.
     */
    public Location getErrorLocation() {
        return myErrorLocation;
    }

}
@@ -3568,16 +3568,22 @@
  public 
+final 
 Location
@@ -3643,9 +3643,498 @@
 %0A    %7D%0A%0A
+    /**%0A     * %3Cp%3EAppending the error location to the end of the message if%0A     * we have a %7B@link Location%7D object.%3C/p%3E%0A     *%0A     * @return A %7B@link String%7D object.%0A     */%0A    @Override%0A    public final String getMessage() %7B%0A        StringBuffer sb = new StringBuffer(super.getMessage());%0A        if (myErrorLocation != null) %7B%0A            sb.append(%22 %5B%22);%0A            sb.append(myErrorLocation.toString());%0A            sb.append(%22%5D%22);%0A        %7D%0A%0A        return sb.toString();%0A    %7D%0A%0A
 %7D

Print location information if it is available