1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| package com.battery.device.bts;
|
| import com.battery.device.api.DeviceAdapterException;
|
| public class BtsProtocolException extends DeviceAdapterException
| {
| private static final long serialVersionUID = 1L;
|
| public enum Reason
| {
| UNEXPECTED_COMMAND,
| MALFORMED_XML,
| MISSING_FIELD,
| INVALID_VALUE,
| IDENTITY_MISMATCH,
| INVALID_RESPONSE
| }
|
| private final Reason reason;
|
| public BtsProtocolException(String message)
| {
| this(Reason.INVALID_RESPONSE, message);
| }
|
| public BtsProtocolException(String message, Throwable cause)
| {
| this(Reason.INVALID_RESPONSE, message, cause);
| }
|
| public BtsProtocolException(Reason reason, String message)
| {
| this(reason, message, null);
| }
|
| public BtsProtocolException(Reason reason, String message, Throwable cause)
| {
| super(reason.name(), message, cause);
| this.reason = reason;
| }
|
| /** 返回协议失败分类;构造时未指定分类的取 {@code INVALID_RESPONSE}。 */
| public Reason reason()
| {
| return reason;
| }
| }
|
|