Menu

Error reporting in console

2008-08-30
2013-05-23
  • Denis Golovan

    Denis Golovan - 2008-08-30

    Hi.

    It would be excellent, if error message use a standart for free pascal/delphi method of showing errors in line. Like following:

    //free pascal
    demo.pas(7,1) Fatal: Syntax error, ":" expected but "BEGIN" found

    //delphi
    demo.pas(151) Error: Missing operator or semicolon

    P.S.
    I tend to use emacs as code editor, but jcf does not even print file name :(

    Thanks.

    Best regards,
    Denis

     
    • Denis Golovan

      Denis Golovan - 2008-09-09

      Can I fix it myself and send you a patch?
      I think commandline option will fit fine for such reporting. Am I right?

      Thanks.

       
      • Anthony Steele

        Anthony Steele - 2008-09-09

        A commandline option for verbose or emacs standard  error format?
        I'll have to look at the existing format, see if it's worth keeping.
        I think this is going to be a fairly simple change.

         
        • Denis Golovan

          Denis Golovan - 2008-09-09

          >>A commandline option for verbose or emacs standard error format?

          Well, that's not verbose or something. It's just the way emacs handles makefile output - it must contain type of compiler (or another tool) message - error, warning, etc., full filename, line index and column index.

          More details here -
          http://www.emacswiki.org/cgi-bin/wiki/CreatingYourOwnCompileErrorRegexp
          http://www.tddft.org/programs/octopus/wiki/index.php/Emacs_helpers

          >>I'll have to look at the existing format, see if it's worth keeping.
          >>I think this is going to be a fairly simple change. 

          You are the boss :)

          Thanks.

           
          • Anthony Steele

            Anthony Steele - 2008-09-09

            Ok, here's my attempt at the format:

            procedure TStatusMesssageReceiver.OnReceiveStatusMessage(const psFile, psMessage: string;
            const piY, piX: integer);
            var
              lsPrefix: string;
              lsMessage: string;
            begin
              lsPrefix := '';
              if (Pos('Exception', psMessage) > 0) or (Pos('Error', psMessage) > 0) then
              begin
                lsPrefix := 'Error:';
              end;

              if (piX < 0) or (piY < 0) then
              begin
                // format with no line and col
                lsMessage := Format('%s %s %s', [psFile, lsPrefix, psMessage]);
              end
              else
              begin
                // format with a line and col
                lsMessage := Format('%s(%s,%s) %s %s',
                  [psFile, IntToStr(piY), IntToStr(piX), lsPrefix, psMessage]);
              end;

              WriteLn(lsMessage);
            end;

            No output format switching code yet.  When I run jcf on a file that isn't deplhi source, I get:

            C:\Code\Jcf\Output>jcf -F dunit.ini
            dunit.ini  Formatting file dunit.ini
            dunit.ini(1,1) Error: Exception TEParseError  Expected program, package, library
            , unit
            Near [
            dunit.ini  Aborted due to error

             
            • Denis Golovan

              Denis Golovan - 2008-09-10

              Well, seems like ok. Not tested in real, yet.
              Only one proposition - write full file name (with path, I mean).

              Another thing - we have warning, AFAIK. It'll be useful to tag them similarly.

              P.S. Can you commit it to svn? Or post a diff?

              Thanks.

               
              • Anthony Steele

                Anthony Steele - 2008-09-10

                That code is checked in but commented out.

                 
              • Anthony Steele

                Anthony Steele - 2008-09-11

                I have checked in some code - since looking through the message text to see if it contains "error" etc. is going to go wrong sometimes, I have changed the event proc signature to also take an enumerated message type which will tell you if it's an error, warning or what.

                I'll look at including the path later.

                 
              • Anthony Steele

                Anthony Steele - 2008-09-14

                With regards path, it seems that at present, what you give is what you get:

                e.g.

                C:\Code\Jcf\Output>jcf -F dunit.ini

                dunit.ini(1,1) Error Exception TEParseError

                or

                C:\Code\Jcf\Output>jcf -F c:\code\Jcf\Output\dunit.ini

                c:\code\Jcf\Output\dunit.ini(1,1) Error Exception TEParseError

                Should the path always be expanded?

                 
                • Denis Golovan

                  Denis Golovan - 2008-09-15

                  >> Should the path always be expanded?

                  Hm. I'm not sure, but it seems like current behaviour is correct. I'll check it and post back today :).
                  Thanks.

                   
                • Denis Golovan

                  Denis Golovan - 2008-09-15

                  Tested. Seems like works like a charm. I like it !!! Thanks a lot.

                  Maybe it would be useful to include to jcf emacs option (free pascal error parsing regexp). Maybe to some kind of "extras\emacs" dir:

                  =======skipped================
                  (require 'compile)
                  (pushnew '("^\\([a-zA-Z0-9\\.]+\\)(\\([0-9]+\\),\\([0-9]+\\))\s\\(.*$\\)" 1 2 3)
                           compilation-error-regexp-alist)
                  =======skipped================

                   
    • Denis Golovan

      Denis Golovan - 2008-09-15

      I forgot to mention - not meInputError, but mtInputError constant :) Please correct

       
      • Anthony Steele

        Anthony Steele - 2008-09-15

        oops! I had fixed that, but not checked it in yet. Done now. 

        I think that this format will be the only (or default?) layout.

         
        • Denis Golovan

          Denis Golovan - 2008-09-16

          >> I think that this format will be the only (or default?) layout.

          Long live strong standarts :)

           
  • Anthony Steele

    Anthony Steele - 2008-09-09

    Hi

    A patch would be excellent. 

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.