1 package org.jpl7; 2 3 /** 4 * PrologException instances wrap Prolog exceptions thrown (either by a Prolog 5 * engine or by user code) in the course of finding a solution to a Query. See 6 * JPLException for the handling of errors within the JPL Java-calls-Prolog 7 * interface. 8 * <p> 9 * This class allows Java code which uses JPL's Java-calls-Prolog API to handle 10 * Prolog exceptions, which is in general necessary for hybrid Java+Prolog 11 * programming. 12 * <p> 13 * Use the term() accessor to obtain a Term representation of the term that was 14 * thrown from within Prolog. 15 * 16 * <hr> 17 * Copyright (C) 2004 Paul Singleton 18 * <p> 19 * Copyright (C) 1998 Fred Dushin 20 * <p> 21 * Redistribution and use in source and binary forms, with or without 22 * modification, are permitted provided that the following conditions are met: 23 * 24 * <ol> 25 * <li>Redistributions of source code must retain the above copyright notice, 26 * this list of conditions and the following disclaimer. 27 * 28 * <li>Redistributions in binary form must reproduce the above copyright notice, 29 * this list of conditions and the following disclaimer in the documentation 30 * and/or other materials provided with the distribution. 31 * </ol> 32 * 33 * <p> 34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 37 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 38 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 39 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 42 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 43 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 44 * POSSIBILITY OF SUCH DAMAGE. 45 * <hr> 46 * 47 * @author Fred Dushin fadushin@syr.edu 48 * @version $Revision$ 49 */ 50 public final class PrologException extends JPLException { 51 private static final long serialVersionUID = 1L; 52 private Term term_ = null; 53 PrologException(Term term)54 protected PrologException(Term term) { 55 super("PrologException: " + term.toString()); 56 this.term_ = term; 57 } 58 59 /** 60 * @return a reference to the Term thrown by the call to throw/1 61 */ term()62 public Term term() { 63 return this.term_; 64 } 65 } 66