SES Backtrace (Print full error backtrace, optionally capture all exceptions.)

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Solistra, Dec 23, 2014.

    Tags:
  1. Solistra

    Solistra Veteran Veteran

    Messages:
    593
    Likes Received:
    241
    SES Backtrace v1.3 by Solistra


    Summary


    This script provides the missing full error backtrace for RGSS3 as well as a number of features related to exception handling for debugging.


    Normally, the error message given when an exception is encountered provides only the exception information without providing the backtrace; this script rectifies that by displaying the backtrace within the RGSS Console when applicable, potentially logging the backtrace to a file, and allowing script developers to test games with critical bugs without causing the entire engine to crash by optionally swallowing all exceptions.


    Screenshot

    [​IMG]
    License


    This script is made available under the terms of the MIT Expat license. View this page for more detailed information.


    Installation


    Place this script below the SES Core (v2.0 or higher) script (if you are using it) or the Materials header, but above all other custom scripts. This script does not require the SES Core, but it is highly recommended.


    Place this script below any script which aliases or overwrites the Game_Interpreter#update or SceneManager.run methods for maximum compatibility.


    Download


    This script is available from the SES source repository. The specific file to download is 'lib/backtrace.rb'.


    Script authors may also browse the documentation for this script from GitHub Pages.
     
    Last edited by a moderator: Dec 25, 2014
    #1
    Acetonide, Cozzer, Tsukihime and 7 others like this.
  2. ♥SOURCE♥

    ♥SOURCE♥ Too sexy for your party. Member

    Messages:
    693
    Likes Received:
    410
    Top quality, as all of your scripts. I love using it, it's very useful. :)
     
    #2
  3. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,316
    Likes Received:
    2,932
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Awesome!
    I've been using a previous Backtrace script you made and the only problem I had was that I had to play in window mode when I expected an exception or I wouldn't be able to see what was printed in the console. Now I won't have that problem again. Thank you for this :)
     
    #3
    Solistra likes this.
  4. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,293
    Likes Received:
    4,830
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    So, apparently this is better than Cidiomar full error backtrace which is overwrite the main process.

    Good work!
     
    #4
  5. Solistra

    Solistra Veteran Veteran

    Messages:
    593
    Likes Received:
    241
    Cidiomar's script was very useful, but yes, it required a completely custom rgss_main loop which, to be perfectly honest, isn't necessary to collect a full backtrace.


    Also, Cidiomar's version wouldn't let you do horrible, horrible things and keep the game running in "quirks mode" like this script does. Basically, if you're testing a script, feel free to have this script swallow all exceptions -- you can keep testing while your script throws errors left and right. (The "black magic" reference in the screenshot is due to the fact that that message box shows up after a script call which would normally kill the RGSS Player.)


    I have come to call this functionality "useful evil."
     
    #5
    Hudell and TheoAllen like this.
  6. Zeriab

    Zeriab Huggins! Veteran

    Messages:
    1,200
    Likes Received:
    1,253
    First Language:
    English
    Primarily Uses:
    RMXP
    Excellent work Solistra!

    I like your script with its deliciously naugthy features and all.

    I do suggest you unravel this line using white space to show the logic flow better.

          RAISE_EXCEPTIONS ? raise(ex) : (alert_caught(ex) if ALERT ; retry)
    Apart from that bit the code is ready to be gobbled up.

    *hugs*

     - Zeriab
     
    #6
    Solistra likes this.
  7. Solistra

    Solistra Veteran Veteran

    Messages:
    593
    Likes Received:
    241
    I was unsure about doing that myself, honestly, but decided to play golf. The logic flow is also still very apparent to me, though I agree that the else portion of the ternary is a little... obtuse (although perfectly legal).


    Thanks for the suggestion, I may just go ahead and break that up to make it more legible to anyone else working with it.


    Edit: The script has now been updated to version 1.1, which simply breaks up that ternary operation into a more traditional if ... else conditional.
     
    Last edited by a moderator: Dec 24, 2014
    #7
    Zeriab likes this.
  8. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,316
    Likes Received:
    2,932
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    If you feel like improving it further, it would be nice to have an option to only alert the first error, to avoid alert loops.
     
    #8
  9. Solistra

    Solistra Veteran Veteran

    Messages:
    593
    Likes Received:
    241
    Personally, I don't see that feature as an improvement -- if anything, it's obfuscation of an existing problem. This script's main purpose is to aid in the task of debugging errant script behavior, and I consider it a good thing that it continues to alert you to an error if there is one in a loop. If anything, I think that you're misusing the alert feature if you find yourself stuck in such loops often (it was largely provided to aid play testing for people who aren't as familiar with the scripting and debugging process -- an alert appears, and they know to pass the information along to the developer).

    However, I do understand the problem that you're having. Fortunately, this is easy to extend yourself:

    class << SES::Backtrace alias_method :original_alert_caught, :alert_caught def alert_caught(exception, *args, &block) return if @previous && @previous == exception @previous = exception original_alert_caught(exception, *args, &block) endendPlace that code in a new script below the SES Backtrace script and you should have the functionality that you asked for -- alerts for the exception which was previously encountered will be silenced; new alerts will only occur if a different exception is being caught and handled.By the way, with extension in mind, this script will also be updated to version 1.2 sometime in the near future -- the functionality will remain entirely unaffected, but the base script as a whole should be easier to extend with customized behavior.

    Edit: The script has now been officially updated to version 1.2, which simply breaks up some of the core logic in the SES::Backtrace.with_exception_handling method into smaller, more easily extended methods.
     
    Last edited by a moderator: Dec 25, 2014
    #9
    Zeriab, Hudell and ♥SOURCE♥ like this.
  10. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,316
    Likes Received:
    2,932
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Thanks.

    The alert loop is because I was developing a new menu and got some errors in the update method.

    In my case, I will always check the console as soon as an error occur, so having even more alert windows won't make a difference. The problem here was that I couldn't Alt+Tab to the console window because of the alert popping up.

    I won't keep the alert feature turned on when I release a version, I just prefer it over the exception because the exception would close the game before I could check the console. Although it doesn't make a difference anymore, as I can check the backtrace.log file now.
     
    Last edited by a moderator: Dec 25, 2014
    #10
  11. Solistra

    Solistra Veteran Veteran

    Messages:
    593
    Likes Received:
    241
    You could end up with a very large log file in that case -- if you have an exception being thrown with each update and enable appended logging, the file will be written to numerous times each update. Why not simply disable exception raising and alerts, then check your console when you see exceptions start to occur there?


    Really, the logging was also mainly provided for play testers and general users -- it gives them a file that they can simply send to a script writer for debugging purposes. I wouldn't recommend having it generally enabled (of course, that's entirely up to you -- and if you find that workflow useful, don't let me talk you out of doing it).
     
    #11
  12. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,316
    Likes Received:
    2,932
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    It's just that I am used to test the game in FullScreen. If only the console wouldn't close with the game, I wouldn't need it.
     
    #12

Share This Page