/// <summary> /// Handles a parsing error. /// </summary> /// <param name="error">The parsing error that occurred.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="error"/> is <c>null</c>. /// </exception> protected void HandleParseError(MalformedRecordException error) { if (error == null) { throw new ArgumentNullException(nameof(error)); } switch (this.ParseErrorAction) { case ParseErrorAction.ThrowException: throw error; case ParseErrorAction.RaiseEvent: ParseErrorEventArgs e = new ParseErrorEventArgs(error, ParseErrorAction.ThrowException); OnParseError(e); switch (e.Action) { case ParseErrorAction.ThrowException: throw e.Error; case ParseErrorAction.RaiseEvent: throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionMessages.IO_ParseErrorActionInvalidInsideParseErrorEvent, e.Action), e.Error); case ParseErrorAction.SkipToNextLine: SkipToNextLine(); break; default: throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionMessages.IO_ParseErrorActionNotSupported, e.Action), e.Error); } break; case ParseErrorAction.SkipToNextLine: SkipToNextLine(); break; default: throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionMessages.IO_ParseErrorActionNotSupported, this.ParseErrorAction), error); } }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error">The error that occurred.</param> /// <param name="action">The action to take.</param> public ParseErrorEventArgs(MalformedRecordException error, ParseErrorAction action) : base() { this.Error = error; this.Action = action; }