NoSuchMessageException.java
01 /*
02  * Copyright 2010-2013 the original author or authors.
03  *
04  * Licensed under the Apache License, Version 2.0 (the "License");
05  * you may not use this file except in compliance with the License.
06  * You may obtain a copy of the License at
07  *
08  *      http://www.apache.org/licenses/LICENSE-2.0
09  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package griffon.core.i18n;
18 
19 import java.util.Locale;
20 
21 /**
22  @author Alexander Klein
23  @since 1.1.0
24  */
25 public class NoSuchMessageException extends RuntimeException {
26     private String key;
27     private Locale locale;
28 
29     /**
30      * Create a new exception.
31      *
32      @param key    message that could not be resolved for given locale
33      @param locale locale that was used to search for the code within
34      */
35     public NoSuchMessageException(String key, Locale locale) {
36         super("No message found under key '" + key + "' for locale '" + locale + "'.");
37         this.key = key;
38         this.locale = locale;
39     }
40 
41     /**
42      * Create a new exception.
43      *
44      @param key key that could not be resolved for given locale
45      */
46     public NoSuchMessageException(String key) {
47         this(key, Locale.getDefault());
48     }
49 
50     /**
51      * Get the key without a valid value
52      *
53      @return The key
54      */
55     public String getKey() {
56         return key;
57     }
58 
59     /**
60      * Get the locale without a valid value
61      *
62      @return The locale
63      */
64     public Locale getLocale() {
65         return locale;
66     }
67 }