/// <summary></summary> /// <param name="type"></param> /// <param name="noThrow">Does the caller want exceptions to be thrown on errors?</param> /// <param name="input"></param> /// <param name="errorState"></param> /// <returns>True if no error handling was needed. Else, an exception is throw (if allowed)</returns> static bool ParseHandleError(ParseErrorType type, bool noThrow, string input , TextStreamReadErrorState errorState) { Exception detailsException = null; switch (type) { case ParseErrorType.NoInput: if (noThrow) { return(false); } detailsException = new ArgumentException ("Input null or empty", nameof(input)); break; case ParseErrorType.InvalidValue: detailsException = new ArgumentException(string.Format (Util.InvariantCultureInfo, "Couldn't parse \"{0}\"", input), nameof(input)); break; default: return(true); } if (noThrow == false) { errorState.ThrowReadExeception(detailsException); } errorState.LogReadExceptionWarning(detailsException); return(true); }
/// <summary>Throws a <see cref="Text.TextLineInfoException"/></summary> /// <param name="detailsException">The details (inner) exception of what went wrong</param> public sealed override void ThrowReadException(Exception detailsException) => mReadErrorState.ThrowReadExeception(detailsException);