public static bool GetErrorStrings(this OffAmazonPaymentsServiceException exception, out string shortMessage, out string fullMessage) { shortMessage = fullMessage = null; try { if (exception.Message.HasValue()) { shortMessage = exception.Message; var sb = new StringBuilder(); sb.AppendLine("Caught Exception: " + exception.Message); sb.AppendLine("Response Status Code: " + exception.StatusCode); sb.AppendLine("Error Code: " + exception.ErrorCode); sb.AppendLine("Error Type: " + exception.ErrorType); sb.AppendLine("Request ID: " + exception.RequestId); sb.AppendLine("XML: " + exception.XML); if (exception.ResponseHeaderMetadata != null) { sb.AppendLine("ResponseHeaderMetadata: " + exception.ResponseHeaderMetadata.ToString()); } fullMessage = sb.ToString(); } } catch (Exception) { } return(shortMessage.HasValue()); }
public static void PrintException(OffAmazonPaymentsServiceException ex) { Console.WriteLine("Caught Exception: " + ex.Message); Console.WriteLine("Response Status Code: " + ex.StatusCode); Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine("Error Type: " + ex.ErrorType); Console.WriteLine("Request ID: " + ex.RequestId); Console.WriteLine("XML: " + ex.XML); Console.WriteLine("ResponseHeaderMetadata: " + ex.ResponseHeaderMetadata); }
public void LogAmazonError(OffAmazonPaymentsServiceException exception, bool notify = false, IList<string> errors = null) { try { string shortMessage, fullMessage; if (exception.GetErrorStrings(out shortMessage, out fullMessage)) { Logger.InsertLog(LogLevel.Error, shortMessage, fullMessage); if (notify) _services.Notifier.Error(new LocalizedString(shortMessage)); if (errors != null) errors.Add(shortMessage); } } catch (Exception) { } }