Handle errors from server
This commit is contained in:
parent
fdf8a07a5d
commit
2f119b81af
|
@ -131,8 +131,13 @@ class Connection(object):
|
||||||
if protocol.Add.isClassOf(v): return self._lookup(v[0])._add(v[1])
|
if protocol.Add.isClassOf(v): return self._lookup(v[0])._add(v[1])
|
||||||
if protocol.Del.isClassOf(v): return self._lookup(v[0])._del(v[1])
|
if protocol.Del.isClassOf(v): return self._lookup(v[0])._del(v[1])
|
||||||
if protocol.Msg.isClassOf(v): return self._lookup(v[0])._msg(v[1])
|
if protocol.Msg.isClassOf(v): return self._lookup(v[0])._msg(v[1])
|
||||||
|
if protocol.Err.isClassOf(v): return self._on_error(v[0])
|
||||||
if protocol.Ping.isClassOf(v): self._send(self._encode(protocol.Pong()))
|
if protocol.Ping.isClassOf(v): self._send(self._encode(protocol.Pong()))
|
||||||
|
|
||||||
|
def _on_error(self, detail):
|
||||||
|
log.error('%s: error from server: %r' % (self.__class__.__qualname__, detail))
|
||||||
|
self._disconnect()
|
||||||
|
|
||||||
def _send(self, bs):
|
def _send(self, bs):
|
||||||
raise Exception('subclassresponsibility')
|
raise Exception('subclassresponsibility')
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ Message = Record.makeConstructor('Message', 'body')
|
||||||
Add = Record.makeConstructor('Add', 'endpointName captures')
|
Add = Record.makeConstructor('Add', 'endpointName captures')
|
||||||
Del = Record.makeConstructor('Del', 'endpointName captures')
|
Del = Record.makeConstructor('Del', 'endpointName captures')
|
||||||
Msg = Record.makeConstructor('Msg', 'endpointName captures')
|
Msg = Record.makeConstructor('Msg', 'endpointName captures')
|
||||||
|
Err = Record.makeConstructor('Err', 'detail')
|
||||||
|
|
||||||
## Bidirectional
|
## Bidirectional
|
||||||
Ping = Record.makeConstructor('Ping', '')
|
Ping = Record.makeConstructor('Ping', '')
|
||||||
|
|
Loading…
Reference in New Issue