01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package com.db4o.internal;
22:
23: import com.db4o.*;
24: import com.db4o.ext.*;
25:
26: /**
27: * @exclude
28: */
29: public class Exceptions4 {
30:
31: public static final void throwRuntimeException(int code) {
32: throwRuntimeException(code, null, null);
33: }
34:
35: public static final void throwRuntimeException(int code,
36: Throwable cause) {
37: throwRuntimeException(code, null, cause);
38: }
39:
40: public static final void throwRuntimeException(int code, String msg) {
41: throwRuntimeException(code, msg, null);
42: }
43:
44: public static final void throwRuntimeException(int code,
45: String msg, Throwable cause) {
46: throwRuntimeException(code, msg, cause, true);
47: }
48:
49: public static final void throwRuntimeException(int code,
50: String msg, Throwable cause, boolean doLog) {
51: if (doLog) {
52: Messages.logErr(Db4o.configure(), code, msg, cause);
53: }
54: throw new Db4oException(Messages.get(code, msg));
55: }
56:
57: /**
58: * @deprecated Use com.db4o.foundation.NotSupportedException instead
59: */
60: public static final void notSupported() {
61: throwRuntimeException(53);
62: }
63:
64: public static final void catchAllExceptDb4oException(Throwable exc)
65: throws Db4oException {
66: if (exc instanceof Db4oException) {
67: throw (Db4oException) exc;
68: }
69: }
70:
71: public static RuntimeException shouldNeverBeCalled() {
72: throw new RuntimeException();
73: }
74:
75: public static void shouldNeverHappen() {
76: throw new Error();
77: }
78:
79: public static RuntimeException virtualException() {
80: throw new RuntimeException();
81: }
82: }
|