package be.iminds.ilabt.jfed.rspec.parser;

import javax.xml.stream.Location;

/**
 * RspecParseException
 */
public class RspecParseException extends Exception {
    private final Location staxLocation;

    public static String locationToString(Location l) {
        if (l == null)
            return "no location info";
        return "line="+l.getLineNumber()+" col="+l.getColumnNumber();
    }

    public RspecParseException(Location staxLocation) {
        this.staxLocation = staxLocation;
    }

    public RspecParseException(Location staxLocation, String message) {
        super(message + " @ " + locationToString(staxLocation));
        this.staxLocation = staxLocation;
    }

    public RspecParseException(Location staxLocation, String message, Throwable cause) {
        super(message + " @ " + locationToString(staxLocation), cause);
        this.staxLocation = staxLocation;
    }

    public RspecParseException(Location staxLocation, Throwable cause) {
        super(cause);
        this.staxLocation = staxLocation;
    }

    public Location getStaxLocation() {
        return staxLocation;
    }
}
