Skip to content

[FR] Error format like visual studio #1

@GoogleCodeExporter

Description

@GoogleCodeExporter
please, make error format like visual studio: <file>(<line>,<col>): error 
<Tool-short-name><error-number>: <error-message>
example:
UbbParser.peg(7,20): error Peg1: Expected whitespace or identifier or comment

With this error format Visual Studio allowed quick go to error place in 
peg-file.

Required changes in code:
[Serializable]
internal sealed class ParserException : Exception
{
    public ParserException()
    {
    }

    public ParserException(string message) : base(message)
    {
    }

    public ParserException(int line, int col, string file, string message) : 
    this(line, col, file, message, (Exception)null)
    {
    }

    public ParserException(int line, int col, string file, string format, params object[] args) : 
    this(line, col, file, string.Format(format, args))
    {
    }

    public ParserException(int line, int col, string file, string message, Exception inner) :
    base(message, inner)
    {
    this.Line = line;
    this.Column = col;
    this.File = file;
    }
  public readonly int? Line;
  public readonly int? Column;
  public string File;

    [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
    private ParserException(SerializationInfo info, StreamingContext context) : base(info, context)
    {
    }
}


Main:
...
if (ms_verbosity == 0)
  Console.Error.WriteLine("{0}({1},{2}): error Peg1: {3}", e.File, e.Line, e.Column, e.Message);
...

private static void DoGenerate(string pegFile)
{
    try
    {
...
    }
    catch (ParserException e)
    {
      if (e.File == null)
        e.File = pegFile;
      throw;
    }
}


Original issue reported on code.google.com by DarkGray...@gmail.com on 20 Aug 2010 at 8:57

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions