KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > CayenneException


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne;
21
22 import org.apache.cayenne.util.LocalizedStringsHandler;
23
24 /**
25  * A generic checked exception that may be thrown by Cayenne framework. All checked
26  * exceptions in Cayenne inherit from this class.
27  *
28  * @author Andrus Adamchik
29  */

30 public class CayenneException extends Exception JavaDoc {
31
32     private static String JavaDoc exceptionLabel;
33
34     static {
35         String JavaDoc version = LocalizedStringsHandler.getString("cayenne.version");
36         String JavaDoc date = LocalizedStringsHandler.getString("cayenne.build.date");
37
38         if (version != null || date != null) {
39             exceptionLabel = "[v." + version + " " + date + "] ";
40         }
41         else {
42             exceptionLabel = "";
43         }
44     }
45
46     public static String JavaDoc getExceptionLabel() {
47         return exceptionLabel;
48     }
49
50     /**
51      * Creates new <code>CayenneException</code> without detail message.
52      */

53     public CayenneException() {
54     }
55
56     /**
57      * Constructs an <code>CayenneException</code> with the specified detail message.
58      *
59      * @param message the detail message.
60      */

61     public CayenneException(String JavaDoc message) {
62         super(message);
63     }
64
65     /**
66      * Constructs an <code>CayenneException</code> that wraps a <code>cause</code>
67      * thrown elsewhere.
68      */

69     public CayenneException(Throwable JavaDoc cause) {
70         super(cause);
71     }
72
73     public CayenneException(String JavaDoc message, Throwable JavaDoc cause) {
74         super(message, cause);
75     }
76
77     /**
78      * Returns exception message without Cayenne version label.
79      *
80      * @since 1.1
81      */

82     public String JavaDoc getUnlabeledMessage() {
83         return super.getMessage();
84     }
85
86     public String JavaDoc getMessage() {
87         String JavaDoc message = super.getMessage();
88         return (message != null) ? getExceptionLabel() + message : getExceptionLabel()
89                 + "(no message)";
90     }
91 }
92
Popular Tags