def eb(fail): code = getattr(fail.value, 'code', 'NetStream.Play.Failed') description = util.getFailureMessage(fail) or 'Internal Server Error' self.sendStatus(status.error(code, description)) return fail
def test_status(self): """ Sending a L{status.IStatus} should succeed. """ s = status.error('AnErrorOccurred', 'This is a description', foo='bar') self.stream.sendStatus(s) msg = self.messages.pop() self.assertEqual(self.messages, []) self.checkMessage(msg, level='error', code='AnErrorOccurred', description='This is a description', extra={'foo': 'bar'})
def send_status(result): s = None if isinstance(result, failure.Failure): code = getattr(result.value, 'code', 'NetConnection.Call.Failed') description = util.getFailureMessage(result) or 'Internal Server Error' s = status.error(code, description) else: s = status.status('NetStream.Publish.Start', description='%s is now published.' % (name,), clientid=self.client.id) self.sendStatus(s) return result