internal ProcessingErrorEventArgs(RecordProcessingException exception) { this.Exception = exception; this.RecordNumber = exception.RecordNumber; ColumnProcessingException columnException = exception.InnerException as ColumnProcessingException; if (columnException != null) { this.Schema = columnException.Schema; this.ColumnDefinition = columnException.ColumnDefinition; this.ColumnValue = columnException.ColumnValue; } }
private string FormatWithContext(IColumnContext columnContext, object value) { try { var definition = columnContext.ColumnDefinition; return(definition.Format(columnContext, value)); } catch (Exception exception) { var columnException = new ColumnProcessingException(columnContext, value, exception); if (columnContext.RecordContext is IRecoverableRecordContext recordContext && recordContext.HasHandler) { var e = new ColumnErrorEventArgs(columnException); recordContext.ProcessError(this, e); if (e.IsHandled) { return((string)e.Substitution); } } throw columnException; } }
private object ParseWithContext(IColumnContext columnContext, string rawValue) { try { var definition = columnContext.ColumnDefinition; object parsedValue = definition.Parse(columnContext, rawValue); return(parsedValue); } catch (Exception exception) { var columnException = new ColumnProcessingException(columnContext, rawValue, exception); if (columnContext.RecordContext is IRecoverableRecordContext recordContext && recordContext.HasHandler) { var e = new ColumnErrorEventArgs(columnException); recordContext.ProcessError(this, e); if (e.IsHandled) { return(e.Substitution); } } throw columnException; } }
internal ColumnErrorEventArgs(ColumnProcessingException exception) { this.exception = exception; }