From f3d93a4e9f0a843867548574b44ff9910591c566 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 19 Aug 2013 11:25:38 +1000 Subject: [PATCH] ConnectionStringParser swallows stack trace the catch was redundant. the message can be derived from the stack trace also it did not add the inner exception which would obscure the debugging experience --- .../Config/ConnectionStringParser.cs | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/RabbitMQ/NServiceBus.RabbitMQ/Config/ConnectionStringParser.cs b/src/RabbitMQ/NServiceBus.RabbitMQ/Config/ConnectionStringParser.cs index 14c409266b..fd99271c77 100644 --- a/src/RabbitMQ/NServiceBus.RabbitMQ/Config/ConnectionStringParser.cs +++ b/src/RabbitMQ/NServiceBus.RabbitMQ/Config/ConnectionStringParser.cs @@ -1,43 +1,38 @@ -using IHostConfiguration = EasyNetQ.IHostConfiguration; - -namespace NServiceBus.Transports.RabbitMQ.Config +namespace NServiceBus.Transports.RabbitMQ.Config { - using System; - using System.Collections.Generic; using System.ComponentModel; using System.Data.Common; using System.Text.RegularExpressions; - using EasyNetQ; using System.Linq; public class ConnectionStringParser : DbConnectionStringBuilder, IConnectionStringParser { ConnectionConfiguration connectionConfiguration; + public IConnectionConfiguration Parse(string connectionString) { ConnectionString = connectionString; - try - { - connectionConfiguration = new ConnectionConfiguration(); - - foreach(var pair in - (from property in typeof(ConnectionConfiguration).GetProperties() - let match = Regex.Match(connectionString, string.Format("[^\\w]*{0}=(?<{0}>[^;]+)", property.Name), RegexOptions.IgnoreCase) - where match.Success - select new { Property = property, match.Groups[property.Name].Value })) - pair.Property.SetValue(connectionConfiguration, TypeDescriptor.GetConverter(pair.Property.PropertyType).ConvertFromString(pair.Value),null); + connectionConfiguration = new ConnectionConfiguration(); - if (ContainsKey("host")) - connectionConfiguration.ParseHosts(this["host"] as string); + foreach (var pair in + (from property in typeof(ConnectionConfiguration).GetProperties() + let match = Regex.Match(connectionString, string.Format("[^\\w]*{0}=(?<{0}>[^;]+)", property.Name), RegexOptions.IgnoreCase) + where match.Success + select new + { + Property = property, + match.Groups[property.Name].Value + })) + pair.Property.SetValue(connectionConfiguration, TypeDescriptor.GetConverter(pair.Property.PropertyType).ConvertFromString(pair.Value), null); - connectionConfiguration.Validate(); - return connectionConfiguration; - } - catch (Exception parseException) + if (ContainsKey("host")) { - throw new Exception(string.Format("Connection String parsing exception {0}", parseException.Message)); + connectionConfiguration.ParseHosts(this["host"] as string); } + + connectionConfiguration.Validate(); + return connectionConfiguration; } } } \ No newline at end of file