Runtime error : concerned line number

Issue #63 resolved
Benjamin Hoffmann created an issue

It would be great to return the line number when a runtime error occurred :

ERROR: Runtime error in TELEPORTATION(73925) - Process 128444 not active

To :

ERROR: Runtime error in TELEPORTATION(73925) Line 648 - Process 128444 not active

Comments (1)

  1. Joseba Echevarria García repo owner

    Thanks for reporting.

    You can get that info by compiling your DCB with debug information and running it with debugging on. Be sure to run your code from the same directory where your compiled it from so that the interpreter can read the source code when launching the DCB.

    Tested by running the following command:

    pxtb -g test.prg && pxtp -d test.dcb
    

    On the following code:

    import "mod_video"
    import "mod_key"
    import "mod_text"
    
    Process test()
    Begin
        while(!key(_enter))
            FRAME;
        End;
    
        write(0, 400, 315, 4, "Now press space");
    End
    
    Process main()
    Private
    int pid = 0;
    Begin
        set_mode(800, 600);
        write(0, 400, 300, 4, "Press enter");
        pid = test();
    
        while(! key(_esc))
            if(key(_space))
                pid.x = 50;
            end
            FRAME;
        End;
    End
    

    [Edit] You'll get something like the following:

    Loading... libgrbase.fakelib
    Loading... libvideo.fakelib
    Loading... libblit.fakelib
    Loading... librender.fakelib
    Loading... mod_video.fakelib
    Loading... libsdlhandler.fakelib
    Loading... libkey.fakelib
    Loading... mod_key.fakelib
    Loading... libfont.fakelib
    Loading... libtext.fakelib
    Loading... mod_text.fakelib
    Renderer info:
    ==============
    Accelerated rendering: 1
    Render to texture:     1
    Rendering driver:      opengl
    VSYNC:                 0
    Max texture size:      8192x8192
    Renderer size:         320x240
    
    # Bunch of stuff
    
    >>> Instance:MAIN ProcID:65536 StackUsed:0/4096
    test.prg:27         End;
    test.prg:22         while(! key(_esc))
    test.prg:23         if(key(_space))
    test.prg:24         pid.x = 50;
    ERROR: Runtime error in MAIN(65536) - Process 65537 not active
    

    And you'll know that your problem is in line 24 of test.prg

  2. Log in to comment