Skip to content

Commit b3f29c2

Browse files
Merge pull request #883 from bcgov/feature/registration-validation
Registration validation
2 parents 842cf72 + 569e71e commit b3f29c2

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

server/StrDss.Service/PermitValidationService.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
using Microsoft.Extensions.Logging;
22
using StrDss.Common;
3-
using StrDss.Data.Entities;
4-
using StrDss.Model;
53
using StrDss.Service.HttpClients;
6-
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
9-
using System.Text;
10-
using System.Threading.Tasks;
114
using Microsoft.Extensions.Configuration;
12-
using Microsoft.Extensions.Logging;
13-
using System.Text.RegularExpressions;
145
using StrDss.Service;
156

167
namespace StrDss.Service
@@ -60,16 +51,22 @@ public PermitValidationService(IRegistrationApiClient regApiClient, IConfigurati
6051
{
6152
isValid = false;
6253
if (resp.Errors.Count == 0)
54+
{
6355
errorDetails.Add("UNKNOWN ERROR", new List<string> { "Response did not contain a status or error message." });
56+
_logger.LogError("Response did not contain a status or error message.");
57+
}
6458
else
59+
{
6560
errorDetails = resp.Errors
6661
.GroupBy(e => e.Code)
6762
.ToDictionary(g => g.Key, g => g.Select(e => e.Message).ToList());
63+
}
6864
}
6965
else if (!string.Equals(resp.Status, "ACTIVE", StringComparison.OrdinalIgnoreCase))
7066
{
7167
isValid = false;
7268
errorDetails.Add("INACTIVE PERMIT", new List<string> { "Error: registration status returned as " + resp.Status });
69+
_logger.LogError("Registration status returned as " + resp.Status);
7370
}
7471
}
7572
catch (ApiException ex)
@@ -87,11 +84,13 @@ public PermitValidationService(IRegistrationApiClient regApiClient, IConfigurati
8784
{
8885
errorDetails.Add("EXCEPTION", new List<string> { "Error: Service threw an undhandled exception." });
8986
}
87+
_logger.LogError($"API Exception: {ex.StatusCode} - {ex.Message}", ex);
9088
}
9189
catch (Exception ex)
9290
{
9391
isValid = false;
9492
errorDetails.Add("EXCEPTION", new List<string> { "Error: Service threw an undhandled exception." });
93+
_logger.LogError($"General Exception: {ex.Message}", ex);
9594
}
9695

9796
return (isValid, errorDetails);

0 commit comments

Comments
 (0)