001package uk.ac.ebi.pride.jmztab2.utils.errors;
002
003/**
004 * Wrap a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError}. This exception mainly used in parse the metadata section of mzTab file.
005 * Once raise exception, system will stop validate and output the error messages.
006 *
007 * NOTICE: In some special situation, the consistency constraints SHOULD be maintain in metadata section,
008 * for example: the assay[n]-sample_ref, study_variable[1-n]-assay_refs and so on. We suggest user raise
009 * this exception very carefully, because of this break the continuous validate principle. During process
010 * the value format, system will add the {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError} into {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabErrorList}, instead of raise
011 * the exception directly. And all errors will output after validate the whole mzTab file.
012 *
013 * @author qingwei
014 * @since 29/01/13
015 * 
016 */
017public class MZTabException extends Exception {
018    private MZTabError error;
019
020    /**
021     * <p>Constructor for MZTabException.</p>
022     *
023     * @param message a {@link java.lang.String} object.
024     */
025    public MZTabException(String message) {
026        super(message);
027    }
028
029    /**
030     * <p>Constructor for MZTabException.</p>
031     *
032     * @param error a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError} object.
033     */
034    public MZTabException(MZTabError error) {
035        super(error.toString());
036        this.error = error;
037    }
038
039    /**
040     * <p>Constructor for MZTabException.</p>
041     *
042     * @param error a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError} object.
043     * @param cause a {@link java.lang.Throwable} object.
044     */
045    public MZTabException(MZTabError error, Throwable cause) {
046        super(error.toString(), cause);
047        this.error = error;
048    }
049
050    /**
051     * <p>Getter for the field <code>error</code>.</p>
052     *
053     * @return a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError} object.
054     */
055    public MZTabError getError() {
056        return error;
057    }
058}