Source code: com/mysql/jdbc/AssertionFailedException.java
1 /*
2 Copyright (C) 2002-2004 MySQL AB
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of version 2 of the GNU General Public License as
6 published by the Free Software Foundation.
7
8
9 There are special exceptions to the terms and conditions of the GPL
10 as it is applied to this software. View the full text of the
11 exception exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
12 software distribution.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 */
24 package com.mysql.jdbc;
25
26
27 /**
28 * Assertions for empty code paths that should never be
29 * executed.
30 *
31 * @author Mark Matthews
32 *
33 * @version $Id: AssertionFailedException.java,v 1.1.2.5 2004/08/09 22:15:11 mmatthew Exp $
34 */
35 public class AssertionFailedException extends RuntimeException {
36 /**
37 * Creates an AssertionFailedException for the given exception
38 * that should never have been thrown.
39 *
40 * @param ex the exception that should never have been thrown.
41 */
42 public AssertionFailedException(Exception ex) {
43 super("ASSERT FAILS: Exception " + ex.toString()
44 + " that should not be thrown, was thrown");
45 }
46
47 /**
48 * Convenience method.
49 *
50 * @param ex the exception that should never have been thrown.
51 * @throws AssertionFailedException for the exception ex.
52 */
53 public static void shouldNotHappen(Exception ex)
54 throws AssertionFailedException {
55 throw new AssertionFailedException(ex);
56 }
57 }