1 | package geniusweb.protocol;
|
---|
2 |
|
---|
3 | import geniusweb.actions.PartyId;
|
---|
4 | import geniusweb.references.PartyRef;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * thrown if a Party violates the protocols (that includes disconnecting).
|
---|
8 | */
|
---|
9 | public class ProtocolException extends Exception {
|
---|
10 | private static final long serialVersionUID = 4618901784366523980L;
|
---|
11 | private PartyId party; // the failing party
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * @param message the error message
|
---|
15 | * @param party offending party, either the {@link PartyId} or a
|
---|
16 | * {@link PartyRef}. In exceptional cases this can be null,
|
---|
17 | * eg if it can not be determined which party failed. Null
|
---|
18 | * should be avoided if possible at all.
|
---|
19 | */
|
---|
20 | public ProtocolException(String message, PartyId party) {
|
---|
21 | this(message, party, null);
|
---|
22 | }
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * ProtocolException is special, in that it does not auto-fill the
|
---|
26 | * stacktrace. This is needed because usually a ProtocolException is caused
|
---|
27 | * by a party doing a bad action. Creating a stacktrace pointing to the
|
---|
28 | * class reporting the protocol exception (usually, the protocol handler)
|
---|
29 | * makes no sense as the protocol handler is doing the correct job there.
|
---|
30 | *
|
---|
31 | *
|
---|
32 | * @param message the error message
|
---|
33 | * @param party offending {@link PartyId}. In exceptional cases this can
|
---|
34 | * be null, eg if it can not be determined which party
|
---|
35 | * failed. Null should be avoided if possible at all.
|
---|
36 | * @param e the cause of the error
|
---|
37 | */
|
---|
38 | public ProtocolException(String message, PartyId party, Throwable e) {
|
---|
39 | super(party + ":" + message, e, true, false);
|
---|
40 | this.party = party;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | *
|
---|
45 | * @return offending party, either the {@link PartyId} or a
|
---|
46 | * {@link PartyRef}. In exceptional cases this can be null.
|
---|
47 | */
|
---|
48 | public PartyId getParty() {
|
---|
49 | return party;
|
---|
50 | }
|
---|
51 |
|
---|
52 | }
|
---|