public void VerifyToStringWithInnerException() { var exception = new YamlException("Test exception message", new InvalidOperationException("Test inner exception")); exception.ToString().Should().Be("(Line: 1, Col: 1, Idx: 0) - (Line: 1, Col: 1, Idx: 0): Test exception message"); exception.Message.Should().Be("Test exception message"); }
public void VerifyToStringWithInnerExceptionAndMarks() { var exception = new YamlException(new Mark(1, 1, 1), new Mark(10, 10, 10), "Test exception message", new InvalidOperationException("Test inner exception")); exception.ToString().Should().Be("(Line: 1, Col: 1, Idx: 1) - (Line: 10, Col: 10, Idx: 10): Test exception message"); exception.Message.Should().Be("Test exception message"); }
public void VerifyToStringWithNonEmptyMarks() { var exception = new YamlException(new Mark(1, 1, 1), new Mark(10, 10, 10), "Test exception message"); exception.ToString().Should().Be("(Line: 1, Col: 1, Idx: 1) - (Line: 10, Col: 10, Idx: 10): Test exception message"); exception.Message.Should().Be("Test exception message"); }
public void VerifyToStringWithEmptyMarks() { var exception = new YamlException(Mark.Empty, Mark.Empty, "Test exception message"); exception.ToString().Should().Be("(Line: 1, Col: 1, Idx: 0) - (Line: 1, Col: 1, Idx: 0): Test exception message"); exception.Message.Should().Be("Test exception message"); }
private static void LogMessage(YamlException exception, IMarkdownParsingContext context) { Logger.Log( (context.LineNumber == 1 ? LogLevel.Warning : LogLevel.Info), $"Invalid yaml header: {exception.Message}", file: context.File, line: context.LineNumber.ToString(), code: WarningCodes.Markdown.InvalidYamlHeader); }
private /*static*/ string GetMessage(YamlException ex) { string inner = null; if (ex.InnerException != null) { inner = " (" + ex.InnerException.Message + ")"; } return(ex.Message + inner); }
public void WhenPassingInvalidLogLevelExceptionIsReturned() { string yamlContent = @" admin: system: loglevel: SOMETHING "; ConfigurationReader reader = new ConfigurationReader(); CascConfiguration conf; YamlException ex = Assert.Throws <YamlException>(() => conf = reader.LoadFromString(yamlContent)); Assert.Matches("Exception during deserialization", ex.Message); Assert.Equal(4, ex.Start.Line); }
public void defaultEncoding(String value, bool valid) { String yamlText = String.Format("defaultEncoding: {0}", value); StringReader reader = new StringReader(yamlText); SettingsYaml parser = new SettingsYaml(); if (!valid) { YamlException error = Assert.Throws <YamlException>(() => parser.deserializeSettings(reader)); Assert.IsType <InvalidArgumentException>(error.InnerException); } else { Settings settings = parser.deserializeSettings(reader); Assert.Equal(value, settings.defaultEncoding.WebName); } }
private static string RetrieveErrorContext(YamlException ex, IEnumerable <string> fileContent) { var possibleLineContent = fileContent.Skip(ex.Start.Line - 1).FirstOrDefault(); return(possibleLineContent ?? string.Empty); }
public ConfigParseException(YamlException innerException) : base($"Your configuration file is invalid and could not be parsed: " + Environment.NewLine + innerException.Message, innerException) { }