01: package org.vraptor.converter;
02:
03: import org.vraptor.VRaptorException;
04: import org.vraptor.i18n.Message;
05: import org.vraptor.i18n.ValidationMessage;
06:
07: /**
08: * Basic convertion exception. Thrown when some conversion problem occurs i.e.
09: * incompatibility or no converter found.
10: *
11: * @author Guilherme Silveira
12: */
13: public class ConversionException extends VRaptorException {
14:
15: /**
16: * serial version uid
17: */
18: private static final long serialVersionUID = 8239876883373338343L;
19:
20: private ValidationMessage i18nMessage;
21:
22: private String category;
23:
24: private String key;
25:
26: public ConversionException(String key, String message,
27: Throwable cause) {
28: super (message, cause);
29: this .key = key;
30: }
31:
32: public ConversionException(String key, String message) {
33: super (message);
34: this .key = key;
35: }
36:
37: public ConversionException(Message message) {
38: super (message.getKey());
39: i18nMessage = message;
40: }
41:
42: public void setCategory(String category) {
43: this .category = category;
44: }
45:
46: public ValidationMessage getI18NMessage() {
47: if (this .i18nMessage != null) {
48: return this .i18nMessage;
49: }
50: return new Message(this.category, this.key);
51: }
52:
53: }
|