Error Log
#1
Error log
Version: 1.5
Same version can be found in rmxp.org.


Introduction

There is already a script about error logging by Me™, but somehow I find it doesn't work all times and gives less information about the error. Since my beta testers sometimes find an error by accident, they fail to note in which line of the script that causes error (and sometimes they can't recreate it). This script, based on Me™, logs an error by the time it happens, hides the normal error message (Script XXX line YYY error message), and replaces it with more user-friendly error message.

Features
  • Logs and appends any error into a file in a human-readable format.
  • Gives player a more user-friendly error message.
The following data is logged:
  1. The time when an error occurs
  2. Error type
  3. The class in which an error occurs
  4. Error message
  5. Error details (list of all methods involved when an error occurs).
Error log example:
Quote:Time: Sun 03 Feb 2008, 22:50:43
Error type: NoMethodError
Class: Scene_Battle
Message: undefined method `ipskilled' for nil:NilClass
at
    IP skill, line 203, at `set_ip_weapon'
    NEW! Scene_BattleEquip, line 113, at `update_item'
    NEW! Scene_BattleEquip, line 110, at `each'
    NEW! Scene_BattleEquip, line 110, at `update_item'
    NEW! Scene_BattleEquip, line 37, at `update_phase_equip'
    Scene_Battle 1, line 461, at `raz_update'
    Enemy HP Bar, line 61, at `update'
    Scene_Battle 1, line 111, at `trick_bars_main'
    Scene_Battle 1, line 105, at `loop'
    Scene_Battle 1, line 116, at `trick_bars_main'
    Extra Modifications, line 19, at `raz_enemy_hp_main'
    Enemy HP Bar, line 53, at `bt_main'
    Customized Battle Test, line 884, at `main'
    Main, baris 14
--------------------
Screenshots

No screenshots provided. It does nothing to the appearance of your game.

Demo

None for now.

Script

Error log

Instructions

Installation
Please backup your game first before attempting to install this script.
1. Go to your Script Editor and scroll through the end of your script. You will find Main.
Yes, this time we will edit the main processing itself (that's why I suggest you to backup first, in case there is something wrong).
2. Before the last end, paste the code above.

A sample Main will be like this:
Sample Main after installation

Custom error message
To replace the custom error message, go to line 25, which says:
Code:
  p "Your error message here. See Instructions for more details."
and edit it as you like. To insert a new line, provide \n. Or, you can use it like this:
Code:
p "First line here", "Second line here", "and so on, as you wish"
Error information are saved in stderr object, which is an Exception (in this case, it's specific to StandardError) class. Refer to RGSS Help on Exception class to display error messages. Basically, you can use stderr.message for error message.

FAQ

None so far. Awaiting questions...

Compatibility

Should work with any script, since it doesn't modify any class but the main processing.

Credits and Thanks

Thank you for Me™ for the base of this script.
Thank you for DerVVulfman, I accidentally found how to get section name from his script.

Author's Notes

I decided not to create a special scene when a error occured, since it wouldn't help so much. It is nicer for your game to have less (and even no) errors, right? So I don't see why I should make a special scene for errors.

This script can only handle StandardError exception, but if you want to handle all exception, replace
Code:
rescue StandardError => stderr
with
Code:
rescue [b]Exception [/b]=> stderr
If you still need the old error message window, I'm sorry, for now it's gone, but you can use p stderr.backtrace to gain similar effect.

The errors are written into ErrorLog.rxdata file, found in your game folder. It is actually a plain text file, so you can open it with Notepad. If you want to use a TXT file instead, change this line:

Code:
File.open("[b]ErrorLog.rxdata[/b]","a+") do |fh|
into anything you wish (e.g. ErrorLog.txt, Error.dat, error.mex, etc.).

Terms and Conditions

You can use this script for free and/or commercial use, as long as you credit Me™. My credit is optional as I only edit his script.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   File Missing Error Preventer xnadvance 0 5,965 05-29-2011, 05:24 AM
Last Post: xnadvance
   Load file error dialog Zeriab 0 4,603 03-06-2008, 06:00 AM
Last Post: Zeriab



Users browsing this thread: 2 Guest(s)