Skip to content

Commit

Permalink
Merge pull request #96 from nightingaleproject/fix-error-log
Browse files Browse the repository at this point in the history
Fixed error log (677)
  • Loading branch information
smacadam authored Nov 6, 2024
2 parents 0e3f62d + e86cf91 commit 46ceeba
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions messaging/Controllers/BundlesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,59 +505,41 @@ 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
{
BaseMessage message = BaseMessage.Parse(bundle);
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");
}

Expand Down

0 comments on commit 46ceeba

Please sign in to comment.