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}
|
---|
17 | */
|
---|
18 | public ProtocolException(String message, PartyId party) {
|
---|
19 | this(message, party, null);
|
---|
20 | }
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * ProtocolException is special, in that it does not auto-fill the
|
---|
24 | * stacktrace. This is needed because usually a ProtocolException is caused
|
---|
25 | * by a party doing a bad action. Creating a stacktrace pointing to the
|
---|
26 | * class reporting the protocol exception (usually, the protocol handler)
|
---|
27 | * makes no sense as the protocol handler is doing the correct job there.
|
---|
28 | *
|
---|
29 | *
|
---|
30 | * @param message the error message
|
---|
31 | * @param party offending {@link PartyId}
|
---|
32 | * @param e the cause of the error
|
---|
33 | */
|
---|
34 | public ProtocolException(String message, PartyId party, Throwable e) {
|
---|
35 | super(party + ":" + message, e, true, false);
|
---|
36 | this.party = party;
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | *
|
---|
41 | * @return offending party, either the {@link PartyId} or a {@link PartyRef}
|
---|
42 | */
|
---|
43 | public PartyId getParty() {
|
---|
44 | return party;
|
---|
45 | }
|
---|
46 |
|
---|
47 | }
|
---|