001/*
002 * jPOS Project [http://jpos.org]
003 * Copyright (C) 2000-2026 jPOS Software SRL
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jpos.iso.validator;
020
021import org.jpos.iso.ISOComponent;
022import org.jpos.iso.ISOException;
023
024/**
025 * This type of exception is raised while validating jPOS ISOComponents.
026 * Contains an error component instance referencing to the error.
027 * <p>Title: jPOS</p>
028 * <p>Description: Java Framework for Financial Systems</p>
029 * <p>Copyright: Copyright (c) 2000 jPOS.org.  All rights reserved.</p>
030 * <p>Company: www.jPOS.org</p>
031 * @author Jose Eduardo Leon
032 * @version 1.0
033 */
034public class ISOVException extends ISOException {
035
036    private static final long serialVersionUID = 8609716526640071611L;
037    /**
038     * Constructs a validator exception with the given message.
039     *
040     * @param Description failure description
041     */
042    public ISOVException( String Description ) {
043        super( Description );
044    }
045
046    /**
047     * Constructs a validator exception with the given message and the offending error component.
048     *
049     * @param Description failure description
050     * @param errComponent the component that produced the error
051     */
052    public ISOVException( String Description, ISOComponent errComponent ) {
053        super( Description );
054        this.errComponent = errComponent;
055    }
056
057    /**
058     * Returns the component that produced the validation error.
059     *
060     * @return the offending {@link ISOComponent}, or {@code null} if not set
061     */
062    public ISOComponent getErrComponent(){
063        return this.errComponent;
064    }
065
066    /**
067     * Indicates whether this exception has already been handled by a {@code catch} clause.
068     *
069     * @return the current treated flag
070     */
071    public boolean treated() {
072        return treated;
073    }
074
075    /**
076     * Replaces the offending component associated with this exception.
077     *
078     * @param c the new error component
079     */
080    public void setErrComponent( ISOComponent c ){
081        this.errComponent = c;
082    }
083
084    /**
085     * Marks this exception as treated (or untreated) by a containing {@code catch} clause.
086     *
087     * @param Treated new treated flag
088     */
089    public void setTreated( boolean Treated ){
090        treated = Treated;
091    }
092
093    /** flag indicating if the exception was catched in any
094     * try/catch clause. It is used to determine if it is
095     * necessary the replacement of the component by the
096     * iso-error-component in the exception instance**/
097    protected boolean treated = false;
098    /** The component flagged by this validation error. */
099    protected ISOComponent errComponent;
100}