From e86cf91cea0788ee38b37a327e417443bf2620ec Mon Sep 17 00:00:00 2001 From: RobertScalfani Date: Thu, 24 Oct 2024 14:13:03 -0400 Subject: [PATCH] Fixed error log --- messaging/Controllers/BundlesController.cs | 50 +++++++--------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/messaging/Controllers/BundlesController.cs b/messaging/Controllers/BundlesController.cs index 7c99279..c6d360c 100644 --- a/messaging/Controllers/BundlesController.cs +++ b/messaging/Controllers/BundlesController.cs @@ -505,33 +505,22 @@ protected virtual string GetNextUri() protected IncomingMessageItem ParseIncomingMessageItem(string jurisdictionId, string vitalType, Bundle bundle) { - //CommonMessage message; - // try parsing as a bfdr message if the vitalType is either unknown or explicitly BFDR - if (_settings.BFDREnabled) + + if (_settings.BFDREnabled && (String.IsNullOrEmpty(vitalType) || vitalType.Equals("BFDR"))) { - if (String.IsNullOrEmpty(vitalType) || vitalType.Equals("BFDR") ) + try { - try - { - CommonMessage message = BirthRecordBaseMessage.Parse(bundle); - return ValidateAndCreateIncomingMessageItem(message, jurisdictionId); - } - catch(BFDR.MessageParseException ex) - { - _logger.LogDebug($"The message could not be parsed as a bfdr message. Trying to parse as a vrdr message..."); - } - catch(ArgumentException aex) - { - // pass exception thrown by our validation to calling function - throw aex; - } + CommonMessage message = BirthRecordBaseMessage.Parse(bundle); + return ValidateAndCreateIncomingMessageItem(message, jurisdictionId); + } + catch (BFDR.MessageParseException) { } + catch (ArgumentException aex) + { + throw aex; } } - - - // try parsing as a vrdr message if the vitalType is either unknown or explicitly VRDR - if (String.IsNullOrEmpty(vitalType) || vitalType.Equals("VRDR") ) + if (String.IsNullOrEmpty(vitalType) || vitalType.Equals("VRDR")) { try { @@ -539,25 +528,18 @@ protected IncomingMessageItem ParseIncomingMessageItem(string jurisdictionId, st BaseMessage.ValidateMessageHeader(message); return ValidateAndCreateIncomingVRDRMessageItem(message, jurisdictionId); } - catch(MessageRuleException mrx) - { - throw mrx; - } - catch(VRDR.MessageParseException ex) + catch (MessageRuleException mrx) { - _logger.LogDebug($"The message could not be parsed as a vrdr message: {ex}"); + throw mrx; } - catch(ArgumentException aex) + catch (VRDR.MessageParseException) { } + catch (ArgumentException aex) { - // pass exception thrown by our validation to calling function throw aex; } } - - - // if we make it here, the message wasn't parsed successfully, throw an error - _logger.LogDebug($"Message type not recognized, throw exception"); + _logger.LogDebug("The message could not be parsed as a BFDR or VRDR message. Throw exception."); throw new ArgumentException("Failed to parse message, message type unrecognized"); }