From 8b7d743dad93402acb358d488aa6ebc87797c861 Mon Sep 17 00:00:00 2001 From: Arek Date: Sun, 27 Jun 2021 16:06:11 +0200 Subject: [PATCH] feat: slightly more expressive exception message More datails in exception during header parsing. --- arstomp/src/Helpers.cs | 2 +- arstomp/src/StompClient.cs | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/arstomp/src/Helpers.cs b/arstomp/src/Helpers.cs index 541caac..7de85e7 100644 --- a/arstomp/src/Helpers.cs +++ b/arstomp/src/Helpers.cs @@ -115,7 +115,7 @@ namespace ArStomp var colon = line.IndexOf(":"); if (colon < 1) // must exist and cannot by first character in the line { - throw new Exception("Cannot parse header"); + throw new Exception($"Cannot parse header: colon not found. Cmd: {cmd}, line: `${line}`"); } var key = line.Substring(0, colon); var value = line.Substring(colon + 1); diff --git a/arstomp/src/StompClient.cs b/arstomp/src/StompClient.cs index 3fdf878..5ea9b31 100644 --- a/arstomp/src/StompClient.cs +++ b/arstomp/src/StompClient.cs @@ -286,15 +286,8 @@ namespace ArStomp var ct = Token.Token; try { - Frame fr = null; - try - { - fr = Helpers.GetFrame(msg.RawData, ct); - } - catch (Exception e) - { - throw e; - } + Frame fr = Helpers.GetFrame(msg.RawData, ct); + if (fr.Type == FrameType.Error) ExpectFrame(fr, FrameType.Message); if (fr.Type == FrameType.Message) {