mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
Made error messages more accurate when we (I) mess up with X# compiler patterns. Inner exceptions are now displayed which allow for more context aware error messages.
This commit is contained in:
parent
b9e88a4e21
commit
d0f674a4e5
3 changed files with 32 additions and 14 deletions
|
|
@ -78,8 +78,11 @@ namespace XSharp.Test {
|
||||||
{
|
{
|
||||||
xProcess.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e)
|
xProcess.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
errorEncountered = true;
|
if (null != e.Data)
|
||||||
if (null != e.Data) { resultCollector.WriteLine("ERROR : " + e.Data); }
|
{
|
||||||
|
errorEncountered = true;
|
||||||
|
resultCollector.WriteLine("ERROR : " + e.Data);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
xProcess.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e)
|
xProcess.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
@ -158,24 +161,28 @@ namespace XSharp.Test {
|
||||||
xOutputCode.WriteLine("============================");
|
xOutputCode.WriteLine("============================");
|
||||||
xOutputCode.WriteLine("Compiling");
|
xOutputCode.WriteLine("Compiling");
|
||||||
compilationError = !LaunchNasm(inputFile.FullName, xOutputCode);
|
compilationError = !LaunchNasm(inputFile.FullName, xOutputCode);
|
||||||
|
if (compilationError) { xOutputCode.WriteLine("Some compilation error."); }
|
||||||
|
else { xOutputCode.WriteLine("Successfully compiled."); }
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
inputFile.Refresh();
|
inputFile.Refresh();
|
||||||
if (!compilationError)
|
if (!compilationError && inputFile.Exists) { inputFile.Delete(); }
|
||||||
{
|
|
||||||
xOutputCode.WriteLine("Successfully compiled.");
|
|
||||||
if (inputFile.Exists) { inputFile.Delete(); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xTbox.Text = xOutputData.ToString() + "\r\n" + xOutputCode.ToString();
|
xTbox.Text = xOutputData.ToString() + "\r\n" + xOutputCode.ToString();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
xTab.Text = "* " + xTab.Text;
|
xTab.Text = "* " + xTab.Text;
|
||||||
xTbox.Text = xOutputData.ToString() + "\r\n"
|
StringBuilder builder = new StringBuilder();
|
||||||
+ xOutputCode.ToString() + "\r\n"
|
|
||||||
+ ex.Message + "\r\n";
|
builder.AppendLine(xOutputData.ToString());
|
||||||
|
builder.AppendLine(xOutputCode.ToString());
|
||||||
|
for (Exception e = ex; null != e; e = e.InnerException)
|
||||||
|
{
|
||||||
|
builder.AppendLine(e.Message);
|
||||||
|
}
|
||||||
|
xTbox.Text = builder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -817,7 +817,12 @@ namespace Cosmos.Compiler.XSharp {
|
||||||
/// pattern reserved syntax.</param>
|
/// pattern reserved syntax.</param>
|
||||||
/// <param name="aCode">The associated code transformation handler.</param>
|
/// <param name="aCode">The associated code transformation handler.</param>
|
||||||
protected void AddPattern(string aPattern, CodeFunc aCode) {
|
protected void AddPattern(string aPattern, CodeFunc aCode) {
|
||||||
var xParser = new Parser(aPattern, 1, false, true);
|
Parser xParser = null;
|
||||||
|
try { new Parser(aPattern, 1, false, true); }
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new Exception(string.Format("Invalid pattern '{0}'", aPattern ?? "NULL"), e);
|
||||||
|
}
|
||||||
var xPattern = new Pattern(xParser.Tokens, aCode);
|
var xPattern = new Pattern(xParser.Tokens, aCode);
|
||||||
mPatterns.Add(xPattern);
|
mPatterns.Add(xPattern);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,15 @@ namespace Cosmos.VS.XSharp {
|
||||||
xResult = xOutputData.ToString() + "\r\n"
|
xResult = xOutputData.ToString() + "\r\n"
|
||||||
+ xOutputCode.ToString() + "\r\n";
|
+ xOutputCode.ToString() + "\r\n";
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
xResult = xOutputData.ToString() + "\r\n"
|
StringBuilder builder = new StringBuilder();
|
||||||
+ xOutputCode.ToString() + "\r\n"
|
|
||||||
+ ex.Message + "\r\n";
|
builder.AppendLine(xOutputData.ToString());
|
||||||
|
builder.AppendLine(xOutputCode.ToString());
|
||||||
|
for (Exception e = ex; null != e; e = e.InnerException)
|
||||||
|
{
|
||||||
|
builder.AppendLine(e.Message);
|
||||||
|
}
|
||||||
|
xResult = builder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue