|
23 | 23 | * |
24 | 24 | */ |
25 | 25 | public class ArangoException extends Exception { |
26 | | - |
27 | | - protected BaseEntity entity; |
28 | | - |
29 | | - public ArangoException() { |
30 | | - super(); |
31 | | - } |
32 | | - |
33 | | - public ArangoException(BaseEntity entity) { |
34 | | - super((entity.getErrorNumber() == 0 ? "" : "[" + entity.getErrorNumber() + "]") + entity.getErrorMessage()); |
35 | | - this.entity = entity; |
36 | | - } |
37 | | - |
38 | | - public ArangoException(String message, Throwable cause) { |
39 | | - super(message, cause); |
40 | | - } |
41 | | - |
42 | | - public ArangoException(String message) { |
43 | | - super(message); |
44 | | - } |
45 | | - |
46 | | - public ArangoException(Throwable cause) { |
47 | | - super(cause); |
48 | | - } |
49 | | - |
50 | | - public int getErrorNumber() { |
51 | | - return (entity == null) ? 0 : entity.getErrorNumber(); |
52 | | - } |
53 | | - |
54 | | - public int getCode() { |
55 | | - return (entity == null) ? 0: entity.getCode(); |
56 | | - } |
57 | | - |
58 | | - public String getErrorMessage() { |
59 | | - return (entity == null) ? getMessage() : entity.getErrorMessage(); |
60 | | - } |
61 | | - |
62 | | - public <T extends BaseEntity> T getEntity() { |
63 | | - return (T) entity; |
64 | | - } |
65 | | - |
66 | | - public boolean isUnauthorized() { |
67 | | - return (entity != null && entity.isUnauthorized()); |
68 | | - } |
69 | | - |
70 | | -// public boolean isNotFound() { |
71 | | -// return (entity != null && entity.isNotFound()); |
72 | | -// } |
73 | | - |
74 | | - public void setCode(int code) { |
75 | | - entity.setCode(code); |
76 | | - } |
77 | | - |
78 | | - public void setErrorNumber(int errorNumber) { |
79 | | - entity.setErrorNumber(errorNumber); |
80 | | - } |
81 | | - |
| 26 | + |
| 27 | + protected BaseEntity entity; |
| 28 | + |
| 29 | + public ArangoException() { |
| 30 | + super(); |
| 31 | + } |
| 32 | + |
| 33 | + public ArangoException(BaseEntity entity) { |
| 34 | + super((entity.getErrorNumber() == 0 ? "" : "[" + entity.getErrorNumber() + "]") + entity.getErrorMessage()); |
| 35 | + this.entity = entity; |
| 36 | + } |
| 37 | + |
| 38 | + public ArangoException(String message, Throwable cause) { |
| 39 | + super(message, cause); |
| 40 | + } |
| 41 | + |
| 42 | + public ArangoException(String message) { |
| 43 | + super(message); |
| 44 | + } |
| 45 | + |
| 46 | + public ArangoException(Throwable cause) { |
| 47 | + super(cause); |
| 48 | + } |
| 49 | + |
| 50 | + public int getErrorNumber() { |
| 51 | + return (entity == null) ? 0 : entity.getErrorNumber(); |
| 52 | + } |
| 53 | + |
| 54 | + public int getCode() { |
| 55 | + return (entity == null) ? 0 : entity.getCode(); |
| 56 | + } |
| 57 | + |
| 58 | + public String getErrorMessage() { |
| 59 | + return (entity == null) ? getMessage() : entity.getErrorMessage(); |
| 60 | + } |
| 61 | + |
| 62 | + public BaseEntity getEntity() { |
| 63 | + return entity; |
| 64 | + } |
| 65 | + |
| 66 | + public boolean isUnauthorized() { |
| 67 | + return (entity != null && entity.isUnauthorized()); |
| 68 | + } |
| 69 | + |
| 70 | + // public boolean isNotFound() { |
| 71 | + // return (entity != null && entity.isNotFound()); |
| 72 | + // } |
| 73 | + |
| 74 | + public void setCode(int code) { |
| 75 | + entity.setCode(code); |
| 76 | + } |
| 77 | + |
| 78 | + public void setErrorNumber(int errorNumber) { |
| 79 | + entity.setErrorNumber(errorNumber); |
| 80 | + } |
| 81 | + |
82 | 82 | } |
0 commit comments