1 /* 2 * Copyright (c) 2004-2007 Creative Sphere Limited. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * 10 * Creative Sphere - initial API and implementation 11 * 12 */ 13 package org.abstracthorizon.mercury.smtp.exception; 14 15 /** 16 * Parser exception 17 * 18 * @author Daniel Sendula 19 */ 20 public class ParserException extends SMTPCommandException { 21 22 /** 23 * Constructor 24 */ 25 public ParserException() { 26 super(); 27 } 28 29 /** 30 * Constructor - it constructs message "Syntax error - expected <" + msg + ">" 31 * @param msg message 32 */ 33 public ParserException(String msg) { 34 this(true, "Syntax error - expected <" + msg + ">"); 35 } 36 37 /** 38 * Constructor 39 * @param missing is message name of missing element 40 * @param msg message 41 */ 42 public ParserException(boolean missing, String msg) { 43 super(compose(missing, msg)); 44 } 45 46 /** 47 * Composes string "Syntax error - expected " + msg. 48 * @param missing is message name of missing element 49 * @param msg message 50 * @return new string 51 */ 52 protected static String compose(boolean missing, String msg) { 53 if (missing) { return "Syntax error - expected " + msg; } 54 return msg; 55 } 56 57 public String toString() { 58 return super.toString(); 59 } 60 }