MZTabException.java

  1. package uk.ac.ebi.pride.jmztab2.utils.errors;

  2. /**
  3.  * Wrap a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError}. This exception mainly used in parse the metadata section of mzTab file.
  4.  * Once raise exception, system will stop validate and output the error messages.
  5.  *
  6.  * NOTICE: In some special situation, the consistency constraints SHOULD be maintain in metadata section,
  7.  * for example: the assay[n]-sample_ref, study_variable[1-n]-assay_refs and so on. We suggest user raise
  8.  * this exception very carefully, because of this break the continuous validate principle. During process
  9.  * 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
  10.  * the exception directly. And all errors will output after validate the whole mzTab file.
  11.  *
  12.  * @author qingwei
  13.  * @since 29/01/13
  14.  *
  15.  */
  16. public class MZTabException extends Exception {
  17.     private MZTabError error;

  18.     /**
  19.      * <p>Constructor for MZTabException.</p>
  20.      *
  21.      * @param message a {@link java.lang.String} object.
  22.      */
  23.     public MZTabException(String message) {
  24.         super(message);
  25.     }

  26.     /**
  27.      * <p>Constructor for MZTabException.</p>
  28.      *
  29.      * @param error a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError} object.
  30.      */
  31.     public MZTabException(MZTabError error) {
  32.         super(error.toString());
  33.         this.error = error;
  34.     }

  35.     /**
  36.      * <p>Constructor for MZTabException.</p>
  37.      *
  38.      * @param error a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError} object.
  39.      * @param cause a {@link java.lang.Throwable} object.
  40.      */
  41.     public MZTabException(MZTabError error, Throwable cause) {
  42.         super(error.toString(), cause);
  43.         this.error = error;
  44.     }

  45.     /**
  46.      * <p>Getter for the field <code>error</code>.</p>
  47.      *
  48.      * @return a {@link uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError} object.
  49.      */
  50.     public MZTabError getError() {
  51.         return error;
  52.     }
  53. }