001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.seq.io;
023
024import org.biojava.bio.BioException;
025
026/**
027 * ParseException should be thrown to indicate that there was a problem with
028 * parsing sequence information.
029 *
030 * @author Matthew Pocock
031 */
032public class ParseException extends BioException {
033  public ParseException() {
034    super();
035  }
036
037  public ParseException(String message) {
038    super(message);
039  }
040
041  public ParseException(Throwable nested) {
042    super(nested);
043  }
044
045  public ParseException(Throwable nested, String message) {
046    super(message, nested);
047  }
048  
049  private static StringBuffer message;
050  private static String intro = "\n\nA Exception Has Occurred During Parsing. \n"+
051          "Please submit the details that follow to biojava-l@biojava.org or "+
052          "post a bug report to http://bugzilla.open-bio.org/ \n\n";
053  /**
054   * Make a new error message.
055   * @param format the format object that was doing the parsing
056   * @param accession the accession number of the record that failed
057   * @param identifier the identifier of the sequence that failed (eg the GI number for genbank)
058   * @param comments any additional information
059   * @param parseBlock the chunk of the file the parser was trying to parse when the error occured
060   * @return the formatted error message
061   */
062  public static String newMessage(Class format, String accession, String identifier, String comments, String parseBlock){
063      message = new StringBuffer();
064      message.append(intro);
065      message.append("Format_object=").append(format.getName()).append('\n');
066      message.append("Accession=").append(accession).append('\n');
067      message.append("Id=").append(identifier).append('\n');
068      message.append("Comments=").append(comments).append('\n');
069      message.append("Parse_block=").append(parseBlock).append('\n');
070      message.append("Stack trace follows ....\n\n");
071      return message.toString();
072  }
073}