/// <summary> /// Loads the YAML data from a stream. /// </summary> /// <param name="stream"> /// The stream to read. /// </param> public override void Load(Stream stream) { var parser = new YamlConfigurationFileParser(); try { Data = parser.Parse(stream); } catch (YamlException ex) { string errorLine = string.Empty; if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); using (var streamReader = new StreamReader(stream)) { var fileContent = ReadLines(streamReader); errorLine = RetrieveErrorContext(ex, fileContent); } } throw new FormatException( "Could not parse the YAML file. " + $"Error on line number '{ex.Start.Line}': '{errorLine}'.", ex); } }
public override void Load(Stream stream) { YamlConfigurationFileParser parser = new YamlConfigurationFileParser(); try { Data = parser.Parse(stream); } catch (YamlException e) { throw new FormatException(Resources.FormatError_YamlParseError(e.Message), e); } }