/// <summary> /// Raise runtime error safely /// </summary> protected virtual void OnRuntimeErrorEvent(RuntimeErrorPacket packet) { var handler = RuntimeErrorEvent; if (handler != null) { handler(packet); } }
/// <summary> /// Display a runtime error /// </summary> private void MessagingOnRuntimeErrorEvent(RuntimeErrorPacket packet) { var rstack = (!string.IsNullOrEmpty(packet.StackTrace) ? (Environment.NewLine + " " + packet.StackTrace) : string.Empty); _logging.Error(packet.Message + rstack); }
public void MessageHandler_SendsCorrectPackets_ToCorrectRoutes() { //Allow proper decoding of orders. JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Converters = { new OrderJsonConverter() } }; // Create list of packets to test var debug = new DebugPacket(); var log = new LogPacket(); var backtest = new BacktestResultPacket(); var handled = new HandledErrorPacket(); var error = new RuntimeErrorPacket(); var packetList = new List <Packet> { log, debug, backtest, handled, error }; using (var pullSocket = new PullSocket(">tcp://localhost:" + _port)) { var count = 0; while (count < packetList.Count) { _messageHandler.Send(packetList[count]); var message = pullSocket.ReceiveMultipartMessage(); var payload = message[0].ConvertToString(); var packet = JsonConvert.DeserializeObject <Packet>(payload); Assert.IsTrue(message.FrameCount == 1); if (PacketType.Debug == packet.Type) { Assert.IsTrue(payload == JsonConvert.SerializeObject(debug)); } if (PacketType.HandledError == packet.Type) { Assert.IsTrue(payload == JsonConvert.SerializeObject(handled)); } if (PacketType.BacktestResult == packet.Type) { Assert.IsTrue(payload == JsonConvert.SerializeObject(backtest)); } if (PacketType.RuntimeError == packet.Type) { Assert.IsTrue(payload == JsonConvert.SerializeObject(error)); } if (PacketType.Log == packet.Type) { Assert.IsTrue(payload == JsonConvert.SerializeObject(log)); } count++; } } }
/// <summary> /// Display a runtime error /// </summary> public void DisplayRuntimeErrorPacket(RuntimeErrorPacket packet) { var rstack = (!string.IsNullOrEmpty(packet.StackTrace) ? (Environment.NewLine + " " + packet.StackTrace) : string.Empty); _logging.Error(packet.Message + rstack); }