source: geniuswebcore/geniusweb/protocol/ProtocolException.py@ 71

Last change on this file since 71 was 71, checked in by Bart Vastenhouw, 3 years ago

LEARN algorithm now also available. Fixed small issues.

File size: 1.2 KB
Line 
1from typing import Optional
2
3from geniusweb.actions.PartyId import PartyId
4
5
6class ProtocolException (Exception) :
7 '''
8 thrown if a Party violates the protocols (that includes disconnecting).
9 '''
10
11 def __init__(self, message:str, party:Optional[PartyId] , e:Optional[Exception]=None):
12 '''
13 ProtocolException is special, in that it does not auto-fill the
14 stacktrace. This is needed because usually a ProtocolException is caused
15 by a party doing a bad action. Creating a stacktrace pointing to the
16 class reporting the protocol exception (usually, the protocol handler)
17 makes no sense as the protocol handler is doing the correct job there.
18
19
20 @param message the error message
21 @param party offending/failing {@link PartyId}. In exceptional cases this can
22 be null, eg if it can not be determined which party
23 failed. Null should be avoided if possible at all.
24 @param e the cause of the error, none if no cause
25 '''
26 super().__init__(str(party) + ":" + message)
27 self.__cause__=e
28 self._party = party
29
30
31 def getParty(self) -> Optional[PartyId] :
32 '''
33 @return offending party, either the {@link PartyId} or a {@link PartyRef}
34 '''
35 return self._party;
Note: See TracBrowser for help on using the repository browser.