Skip to content

Commit 1d18cc1

Browse files
Added Flatten Exception
1 parent c5fe042 commit 1d18cc1

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

AnyAgent/CertManager.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public bool DoesCryptoCertificateObjectExist(CertStoreInfo ci, string cryptoCert
6363
}
6464
catch (Exception ex)
6565
{
66-
Logger.Error($"There was an issue receiving the certificates: {cryptoCertObjectName} Error {ex.Message}");
66+
Logger.Error($"There was an issue receiving the certificates: {cryptoCertObjectName} Error {LogHandler.FlattenException(ex)}");
6767
}
6868
Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);
6969

@@ -95,7 +95,7 @@ public void DisableCryptoCertificateObject(string cryptoCertObjectName, ApiClien
9595
}
9696
catch (Exception ex)
9797
{
98-
Logger.Error($"There was an issue disabling the certificate object: {cryptoCertObjectName} Error {ex.Message}");
98+
Logger.Error($"There was an issue disabling the certificate object: {cryptoCertObjectName} Error {LogHandler.FlattenException(ex)}");
9999
}
100100
}
101101

@@ -118,7 +118,7 @@ public bool DoesCryptoKeyObjectExist(CertStoreInfo ci, string cryptoKeyObjectNam
118118
}
119119
catch (Exception ex)
120120
{
121-
Logger.Error($"Crypto Key Object does not exist: {cryptoKeyObjectName} : {ex.Message}");
121+
Logger.Error($"Crypto Key Object does not exist: {cryptoKeyObjectName} : {LogHandler.FlattenException(ex)}");
122122
}
123123
Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);
124124
return bUpdateCryptoKeyObject;
@@ -148,7 +148,7 @@ public void DisableCryptoKeyObject(string cryptoKeyObjectName, ApiClient apiClie
148148
}
149149
catch (Exception ex)
150150
{
151-
Logger.Error($"There was an issue disabling the certificate *key*: {cryptoKeyObjectName} Error {ex.Message}");
151+
Logger.Error($"There was an issue disabling the certificate *key*: {cryptoKeyObjectName} Error {LogHandler.FlattenException(ex)}");
152152
}
153153
}
154154

@@ -174,7 +174,7 @@ public void UpdatePrivateKey(CertStoreInfo ci, string cryptoKeyObjectName,
174174
}
175175
catch (Exception ex)
176176
{
177-
Logger.Error($"There was an issue updating the private key: {cryptoKeyObjectName} Error {ex.Message}");
177+
Logger.Error($"There was an issue updating the private key: {cryptoKeyObjectName} Error {LogHandler.FlattenException(ex)}");
178178
}
179179
}
180180

@@ -201,7 +201,7 @@ public void AddCryptoKey(CertStoreInfo ci, string cryptoKeyObjectName, ApiClient
201201
}
202202
catch (Exception ex)
203203
{
204-
Logger.Error($"Error Adding CryptoKey Object for Private Key {alias}: {cryptoKeyObjectName} Error {ex.Message}");
204+
Logger.Error($"Error Adding CryptoKey Object for Private Key {alias}: {cryptoKeyObjectName} Error {LogHandler.FlattenException(ex)}");
205205
}
206206
}
207207

@@ -219,7 +219,7 @@ public AnyErrors RemovePrivateKeyFile(AnyJobConfigInfo addConfig, CertStoreInfo
219219
}
220220
catch (Exception e)
221221
{
222-
Logger.Error($"Error In CertManager.RemovePrivateKeyFile: {e.Message}");
222+
Logger.Error($"Error In CertManager.RemovePrivateKeyFile: {LogHandler.FlattenException(e)}");
223223
throw;
224224
}
225225
}
@@ -246,7 +246,7 @@ public CertificateAddRequest AddPrivateKey(CertStoreInfo ci, string alias, strin
246246
}
247247
catch (Exception ex)
248248
{
249-
Logger.Error($"Error Adding Private Key {alias} to CERT store with Filename {keyFileName} Error {ex.Message}");
249+
Logger.Error($"Error Adding Private Key {alias} to CERT store with Filename {keyFileName} Error {LogHandler.FlattenException(ex)}");
250250
}
251251

252252
return null;
@@ -275,7 +275,7 @@ public void UpdateCryptoCert(CertStoreInfo ci, string cryptoCertObjectName,
275275
}
276276
catch (Exception ex)
277277
{
278-
Logger.Error($"Error Updating Crypto Certificate Object: {cryptoCertObjectName} Error {ex.Message}");
278+
Logger.Error($"Error Updating Crypto Certificate Object: {cryptoCertObjectName} Error {LogHandler.FlattenException(ex)}");
279279
}
280280
}
281281

@@ -302,7 +302,7 @@ public void AddCryptoCert(CertStoreInfo ci, string cryptoCertObjectName, ApiClie
302302
}
303303
catch (Exception ex)
304304
{
305-
Logger.Error($"Error Adding Crypto Object for Certificate {alias} to CERT store with Filename {certFileName} Error {ex.Message}");
305+
Logger.Error($"Error Adding Crypto Object for Certificate {alias} to CERT store with Filename {certFileName} Error {LogHandler.FlattenException(ex)}");
306306
}
307307
}
308308

@@ -319,7 +319,7 @@ public AnyErrors RemoveCertificate(AnyJobConfigInfo addConfig, CertStoreInfo ci,
319319
}
320320
catch (Exception e)
321321
{
322-
Logger.Error($"Error In CertManager.RemovePrivateKeyFile: {e.Message}");
322+
Logger.Error($"Error In CertManager.RemovePrivateKeyFile: {LogHandler.FlattenException(e)}");
323323
throw;
324324
}
325325
}
@@ -345,7 +345,7 @@ public CertificateAddRequest CertificateAddRequest(CertStoreInfo ci, string alia
345345
}
346346
catch (Exception ex)
347347
{
348-
Logger.Error($"Error Adding Certificate {alias} with Filename {certFileName} Error {ex.Message}");
348+
Logger.Error($"Error Adding Certificate {alias} with Filename {certFileName} Error {LogHandler.FlattenException(ex)}");
349349
}
350350

351351
return null;
@@ -369,7 +369,7 @@ public bool DoesKeyFileExist(CertStoreInfo ci, string keyFileName, ViewPublicCer
369369
}
370370
catch (Exception ex)
371371
{
372-
Logger.Error($"Error Matching Key File {keyFileName} was found in domain {ci.Domain} Error {ex.Message}");
372+
Logger.Error($"Error Matching Key File {keyFileName} was found in domain {ci.Domain} Error {LogHandler.FlattenException(ex)}");
373373
}
374374
Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);
375375
return bRemoveKeyFile;
@@ -393,7 +393,7 @@ public bool DoesCertificateFileExist(CertStoreInfo ci, ApiClient apiClient,
393393
}
394394
catch (Exception ex)
395395
{
396-
Logger.Error($"Error Matching Certificate File {certFileName} was found in domain {ci.Domain} Error {ex.Message}");
396+
Logger.Error($"Error Matching Certificate File {certFileName} was found in domain {ci.Domain} Error {LogHandler.FlattenException(ex)}");
397397
}
398398
Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);
399399
return bRemoveCertificateFile;
@@ -460,7 +460,7 @@ public string GetCertPem(AnyJobConfigInfo addConfig, string alias, ref string pr
460460
}
461461
catch (Exception ex)
462462
{
463-
Logger.Error($"Error Generating PEM: Error {ex.Message}");
463+
Logger.Error($"Error Generating PEM: Error {LogHandler.FlattenException(ex)}");
464464
}
465465
Logger.Trace($"PEM {certPem}");
466466
Logger.MethodEntry(ILogExtensions.MethodLogLevel.Debug);
@@ -536,7 +536,7 @@ public AnyErrors AddPubCert(AnyJobConfigInfo addPubConfig, CertStoreInfo ci, Nam
536536
catch (Exception ex)
537537
{
538538
error.HasError = true;
539-
Logger.Trace($"Error on {certAlias}: {ex.Message}");
539+
Logger.Trace($"Error on {certAlias}: {LogHandler.FlattenException(ex)}");
540540
apiClient.SaveConfig();
541541
}
542542
Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);
@@ -606,7 +606,7 @@ private AnyErrors RemoveCertFromDomain(AnyJobConfigInfo removeConfig, CertStoreI
606606
{
607607
error.HasError = true;
608608
error.ErrorMessage = ex.Message;
609-
Logger.Trace($"Error on {removeConfig.Job.Alias}: {ex.Message}");
609+
Logger.Trace($"Error on {removeConfig.Job.Alias}: {LogHandler.FlattenException(ex)}");
610610
}
611611
Logger.Trace("Saving Config!");
612612
apiClient.SaveConfig();
@@ -638,7 +638,7 @@ private AnyErrors RemoveFile(AnyJobConfigInfo removeConfig, CertStoreInfo ci, st
638638
{
639639
error.HasError = true;
640640
error.ErrorMessage = ex.Message;
641-
Logger.Trace($"Error on {removeConfig.Job.Alias}: {ex.Message}");
641+
Logger.Trace($"Error on {removeConfig.Job.Alias}: {LogHandler.FlattenException(ex)}");
642642
}
643643
Logger.Trace("Saving Config!");
644644
apiClient.SaveConfig();
@@ -674,7 +674,7 @@ public AnyErrors Remove(AnyJobConfigInfo removeConfig, CertStoreInfo ci, NamePre
674674
}
675675
catch (Exception e)
676676
{
677-
Logger.Error($"Error In CertManager.Remove {e.Message}!");
677+
Logger.Error($"Error In CertManager.Remove {LogHandler.FlattenException(e)}!");
678678
throw;
679679
}
680680
}
@@ -699,7 +699,7 @@ public AnyErrors Add(AnyJobConfigInfo addConfig, CertStoreInfo ci, NamePrefix np
699699
}
700700
catch (Exception e)
701701
{
702-
Logger.Error($"Error In CertManager.Add {e.Message}!");
702+
Logger.Error($"Error In CertManager.Add {LogHandler.FlattenException(e)}!");
703703
throw;
704704
}
705705
}
@@ -785,7 +785,7 @@ private AnyErrors AddCertStore(AnyJobConfigInfo addConfig, CertStoreInfo ci, Nam
785785
catch (Exception ex)
786786
{
787787
error.HasError = true;
788-
Logger.Trace($"Error on {alias}: {ex.Message}");
788+
Logger.Trace($"Error on {alias}: {LogHandler.FlattenException(ex)}");
789789
apiClient.SaveConfig();
790790
}
791791
Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);
@@ -819,7 +819,7 @@ private void ReplacePrivateKey(AnyJobConfigInfo addConfig, CertStoreInfo ci, str
819819
}
820820
catch (Exception e)
821821
{
822-
Logger.Error($"Error in CertManager.ReplacePrivateKey {e.Message}");
822+
Logger.Error($"Error in CertManager.ReplacePrivateKey {LogHandler.FlattenException(e)}");
823823
throw;
824824
}
825825
}
@@ -847,7 +847,7 @@ private void ReplaceCertificateFile(AnyJobConfigInfo addConfig, CertStoreInfo ci
847847
}
848848
catch (Exception e)
849849
{
850-
Logger.Error($"Error in CertManager.ReplaceCertificateFile {e.Message}");
850+
Logger.Error($"Error in CertManager.ReplaceCertificateFile {LogHandler.FlattenException(e)}");
851851
throw;
852852
}
853853
}
@@ -887,7 +887,7 @@ private void ReplaceCryptoKeyObject(CertStoreInfo ci, string cryptoKeyObjectName
887887
}
888888
catch (Exception e)
889889
{
890-
Logger.Error($"Error in CertManager.ReplaceCryptoKeyObject {e.Message}");
890+
Logger.Error($"Error in CertManager.ReplaceCryptoKeyObject {LogHandler.FlattenException(e)}");
891891
throw;
892892
}
893893
}
@@ -929,7 +929,7 @@ private void ReplaceCryptoObject(CertStoreInfo ci, string cryptoCertObjectName,
929929
}
930930
catch (Exception e)
931931
{
932-
Logger.Error($"Error in CertManager.ReplaceCryptoObject {e.Message}");
932+
Logger.Error($"Error in CertManager.ReplaceCryptoObject {LogHandler.FlattenException(e)}");
933933
throw;
934934
}
935935
}
@@ -997,7 +997,7 @@ public InventoryResult GetPublicCerts(ApiClient apiClient)
997997
}
998998
catch (Exception ex)
999999
{
1000-
Logger.Error($"Error on {pc.Name}: {ex.Message}");
1000+
Logger.Error($"Error on {pc.Name}: {LogHandler.FlattenException(ex)}");
10011001
error.ErrorMessage = ex.Message;
10021002
error.HasError = true;
10031003
}
@@ -1010,7 +1010,7 @@ public InventoryResult GetPublicCerts(ApiClient apiClient)
10101010
}
10111011
catch (Exception e)
10121012
{
1013-
Logger.Error($"Error in CertManager.GetPublicCerts {e.Message}");
1013+
Logger.Error($"Error in CertManager.GetPublicCerts {LogHandler.FlattenException(e)}");
10141014
throw;
10151015
}
10161016
}
@@ -1071,7 +1071,7 @@ public InventoryResult GetCerts(ApiClient apiClient)
10711071
}
10721072
catch (Exception ex)
10731073
{
1074-
Logger.Error($"Certificate not retrievable: Error on {cc.Name}: {ex.Message}");
1074+
Logger.Error($"Certificate not retrievable: Error on {cc.Name}: {LogHandler.FlattenException(ex)}");
10751075
error.ErrorMessage = ex.Message;
10761076
error.HasError = true;
10771077
}
@@ -1085,7 +1085,7 @@ public InventoryResult GetCerts(ApiClient apiClient)
10851085
}
10861086
catch (Exception e)
10871087
{
1088-
Logger.Error($"Error in CertManager.GetCerts {e.Message}");
1088+
Logger.Error($"Error in CertManager.GetCerts {LogHandler.FlattenException(e)}");
10891089
throw;
10901090
}
10911091
}

AnyAgent/InventoryManagement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public string GetStoreType()
5151
}
5252
catch (Exception e)
5353
{
54-
Logger.Error($"Error Getting Store Type: {e.Message}");
54+
Logger.Error($"Error Getting Store Type: {LogHandler.FlattenException(e)}");
5555
throw;
5656
}
5757
}

DataPower.API/client/ApiClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public bool SaveConfig()
6262
}
6363
catch (Exception ex)
6464
{
65-
Logger.Error($"Error Saving the Config: {ex.Message}");
65+
Logger.Error($"Error Saving the Config: {LogHandler.FlattenException(ex)}");
6666
return false;
6767
}
6868
}
@@ -296,7 +296,7 @@ public string ApiRequestString(string strCall, string strPostUrl, string strMeth
296296
}
297297
catch (Exception ex)
298298
{
299-
Logger.Trace($"END APIRequestString error: {ex.Message}");
299+
Logger.Trace($"END APIRequestString error: {LogHandler.FlattenException(ex)}");
300300
throw;
301301
}
302302
}

0 commit comments

Comments
 (0)