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; } }
public void ProcessError(object sender, ColumnErrorEventArgs e) { ColumnError?.Invoke(sender, e); }