1
1
using Microsoft . Extensions . Logging ;
2
2
using StrDss . Common ;
3
- using StrDss . Data . Entities ;
4
- using StrDss . Model ;
5
3
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 ;
11
4
using Microsoft . Extensions . Configuration ;
12
- using Microsoft . Extensions . Logging ;
13
- using System . Text . RegularExpressions ;
14
5
using StrDss . Service ;
15
6
16
7
namespace StrDss . Service
@@ -60,16 +51,22 @@ public PermitValidationService(IRegistrationApiClient regApiClient, IConfigurati
60
51
{
61
52
isValid = false ;
62
53
if ( resp . Errors . Count == 0 )
54
+ {
63
55
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
+ }
64
58
else
59
+ {
65
60
errorDetails = resp . Errors
66
61
. GroupBy ( e => e . Code )
67
62
. ToDictionary ( g => g . Key , g => g . Select ( e => e . Message ) . ToList ( ) ) ;
63
+ }
68
64
}
69
65
else if ( ! string . Equals ( resp . Status , "ACTIVE" , StringComparison . OrdinalIgnoreCase ) )
70
66
{
71
67
isValid = false ;
72
68
errorDetails . Add ( "INACTIVE PERMIT" , new List < string > { "Error: registration status returned as " + resp . Status } ) ;
69
+ _logger . LogError ( "Registration status returned as " + resp . Status ) ;
73
70
}
74
71
}
75
72
catch ( ApiException ex )
@@ -87,11 +84,13 @@ public PermitValidationService(IRegistrationApiClient regApiClient, IConfigurati
87
84
{
88
85
errorDetails . Add ( "EXCEPTION" , new List < string > { "Error: Service threw an undhandled exception." } ) ;
89
86
}
87
+ _logger . LogError ( $ "API Exception: { ex . StatusCode } - { ex . Message } ", ex ) ;
90
88
}
91
89
catch ( Exception ex )
92
90
{
93
91
isValid = false ;
94
92
errorDetails . Add ( "EXCEPTION" , new List < string > { "Error: Service threw an undhandled exception." } ) ;
93
+ _logger . LogError ( $ "General Exception: { ex . Message } ", ex ) ;
95
94
}
96
95
97
96
return ( isValid , errorDetails ) ;
0 commit comments