001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002 *
003 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
004 *
005 * "Hilbert II" is free software; you can redistribute
006 * it and/or modify it under the terms of the GNU General Public
007 * License as published by the Free Software Foundation; either
008 * version 2 of the 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 General Public License for more details.
014 */
015
016 package org.qedeq.kernel.bo.logic.common;
017
018 import org.qedeq.kernel.se.base.list.Element;
019 import org.qedeq.kernel.se.common.ModuleContext;
020 import org.qedeq.kernel.se.common.ModuleDataException;
021
022 /**
023 * This is the basis for an exception for logical errors within a QEDEQ module.
024 *
025 * @author Michael Meyling
026 */
027 public abstract class LogicalCheckException extends ModuleDataException {
028
029 /**
030 * This element causes the error.
031 */
032 private final Element element;
033
034 /**
035 * Constructs an exception.
036 *
037 * @param errorCode ErrorCode of this message.
038 * @param message What is the problem.
039 * @param element Problematic line.
040 * @param context Error location.
041 * @param referenceContext Reference location.
042 */
043 public LogicalCheckException(final int errorCode, final String message, final Element element,
044 final ModuleContext context, final ModuleContext referenceContext) {
045 super(errorCode, message, context, referenceContext);
046 this.element = element;
047 }
048
049 /**
050 * Constructs an exception.
051 *
052 * @param errorCode ErrorCode of this message.
053 * @param message What is the problem.
054 * @param element Problematic formula.
055 * @param context Error location.
056 */
057 public LogicalCheckException(final int errorCode, final String message,
058 final Element element, final ModuleContext context) {
059 super(errorCode, message, context);
060 this.element = element;
061 }
062
063 /**
064 * Constructs an exception.
065 *
066 * @param errorCode ErrorCode of this message.
067 * @param message What is the problem.
068 * @param context Error location.
069 */
070 public LogicalCheckException(final int errorCode, final String message,
071 final ModuleContext context) {
072 super(errorCode, message, context);
073 this.element = null;
074 }
075
076 /**
077 * Get the problematic element. Might be <code>null</code>.
078 *
079 * @return Element.
080 */
081 public final Element getElement() {
082 return this.element;
083 }
084
085 /**
086 * Returns a short description of this throwable.
087 * If this <code>Throwable</code> object was created with a non-null detail
088 * message string, then the result is the concatenation of five strings:
089 * <ul>
090 * <li>The name of the actual class of this object
091 * <li>": " (a colon and a space)
092 * <li>The result of the {@link Throwable#getMessage()} method for this object
093 * <li>"\n" (a newline)
094 * <li>A string representation of the {@link #getElement()} method for this object
095 * (might be empty).
096 * </ul>
097 *
098 * @return a string representation of this throwable.
099 */
100 public final String toString() {
101 return super.toString() + "\n"
102 + (getElement() != null ? getElement().toString() : "");
103 }
104
105 }
|