Skip to content

Commit

Permalink
Added informational logging in case of YAML syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Dunham committed May 31, 2012
1 parent 8affc9c commit de58d17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion git-bin/GitBinDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,22 @@ public static string ToYaml(GitBinDocument document)

public static GitBinDocument FromYaml(TextReader textReader )
{
var yaml = textReader.ReadToEnd();

GitBinDocument document;
var serializer = new YamlSerializer<GitBinDocument>();
return serializer.Deserialize(textReader);

try
{
document = serializer.Deserialize(new StringReader(yaml));
}
catch (YamlDotNet.Core.SyntaxErrorException e)
{
GitBinConsole.WriteLine("Syntax error in YAML file: {0}\n\n File contents:{1}\n", e.Message, yaml);
throw;
}

return document;
}
}
}
4 changes: 2 additions & 2 deletions git-bin/git-bin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\..\Utils\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -28,7 +28,7 @@
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\..\..\Utils\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down

0 comments on commit de58d17

Please sign in to comment.