View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2001-2005 Open World Ltd
4   // Copyright (C) 2004 Kevin Rogers
5   //
6   // This file is part of MillScript.
7   //
8   // MillScript is free software; you can redistribute it and/or modify it under
9   // the terms of the GNU General Public License as published by the Free
10  // Software Foundation; either version 2 of the License, or (at your option)
11  // any later version.
12  //
13  // MillScript is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  // more details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // MillScript; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA  02111-1307  USA
21  ////////////////////////////////////////////////////////////////////////////////
22  package org.millscript.commons.alert;
23  
24  /**
25   * Thrown specifically to escape to the top-level.
26   */
27  public final class EscapeException extends RuntimeException {
28  
29      /**
30       * This is the ID from the first release for future compatibility.
31       */
32      private static final long serialVersionUID = 3906369337534002740L;
33  
34      /**
35       * The Alert that lead to this exception.
36       */
37      private final Alert alert;
38  
39      /**
40       * Constructs a new exception for the specified alert.
41       *
42       * @param a the alert which lead to this exception
43       */
44      public EscapeException( final Alert a ) {
45          this.alert = a;
46      }
47  
48      /**
49       * Returns the alert that caused this exception.
50       *
51       * @return  the Alert that caused this expcetion.
52       */
53      public Alert getAlert() {
54          return alert;
55      }
56  
57      /**
58       * @see java.lang.Throwable#toString()
59       */
60      @Override
61      public String toString() {
62          final StringBuffer buffer = new StringBuffer( "Escaped because of the following alert:\n" );
63          buffer.append( this.alert.toString() );
64          return buffer.toString();
65      }
66  
67  }