public static void Handle(FaultException faultException) { Exception innerException = null; if (faultException is FaultException<RecordNotFoundFault>) { var recordNotFoundFault = faultException as FaultException<RecordNotFoundFault>; innerException = new RecordNotFoundException(recordNotFoundFault.Message); } if (faultException is FaultException<InvalidRecordFault>) { var invalidRecordFault = faultException as FaultException<InvalidRecordFault>; innerException = new InvalidRecordException(invalidRecordFault.Message); } if (faultException is FaultException<DuplicateRecordFoundFault>) { var duplicateRecordFault = faultException as FaultException<DuplicateRecordFoundFault>; innerException = new DuplicateRecordFoundException(duplicateRecordFault.Message); } if (innerException == null) { throw faultException; } if (innerException == null) { throw faultException; } throw new StockException("A exception has occured.",innerException); }
private bool LogInvalidRecordException(InvalidRecordException ex) { Debug.WriteLine(ex.ToString()); foreach (var recordError in ex.RecordContext.RecordErrors) { Debug.WriteLine($"Record error: {recordError}"); } foreach (var fieldErrors in ex.RecordContext.GetFieldErrors()) { foreach (var fieldError in fieldErrors) { Debug.WriteLine($"Field error for field {fieldErrors.Key}: {fieldError}"); } } return(false); }