001/*
002 * Copyright (C) 2009-2011 Mathias Doenitz
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.parboiled.errors;
018
019import org.parboiled.buffers.InputBuffer;
020import org.parboiled.support.MatcherPath;
021import org.parboiled.common.Preconditions;
022import org.parboiled.support.MatcherPath;
023
024import static org.parboiled.common.Preconditions.checkArgNotNull;
025
026/**
027 * A {@link ParseError} wrapping an ActionException.
028 */
029public class ActionError extends BasicParseError {
030
031    private final MatcherPath errorPath;
032    private final ActionException actionException;
033
034    public ActionError(InputBuffer inputBuffer, int errorIndex, String errorMessage,
035                       MatcherPath errorPath, ActionException actionException) {
036        super(Preconditions.checkArgNotNull(inputBuffer, "inputBuffer"), errorIndex, errorMessage);
037        this.errorPath = Preconditions.checkArgNotNull(errorPath, "errorPath");
038        this.actionException = Preconditions.checkArgNotNull(actionException, "actionException");
039    }
040
041    /**
042     * Gets the path to the matcher that caused this error.
043     *
044     * @return the MatcherPath
045     */
046    public MatcherPath getErrorPath() {
047        return errorPath;
048    }
049
050    /**
051     * Gets the wrapped ActionException.
052     *
053     * @return the wrapped ActionException
054     */
055    public ActionException getActionException() {
056        return actionException;
057    }
058}