Save-Point
Error reporting extension! - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: Error reporting extension! (/thread-13433.html)



Error reporting extension! - Kayzee - 03-16-2026

Here is a handy script I made a while ago to give more detailed error reports and print them to the console! It gives a full trace of where the error happened and the last called functions so you know what the problem might be! Has some limitations. Sometimes the report is too big for the little popup and it will be blank, but it should show the error in the console! Also doesn't properly trace errors inside events, so that might be something to add later.

Oh! And you can use "Error_Handler.do_trace()" to print a backtrace to the console in scripts whenever you want for debugging too!

Code:
#==============================================================================
# * Error handling functions.
#==============================================================================

module Error_Handler
 
  def self.script_names
    unless @script_names
      @script_names = load_data('Data/Scripts.rvdata2')
      @script_names.collect! {|script|  script[1]  }
    end
    @script_names
  end
 
  def self.do_backtrace(error)
    backtrace = self.parse_trace(error.backtrace)
    error_line = backtrace.first
    backtrace[0] = ''
    return error_line + ": " + error.message + " (#{error.class})" + backtrace.join("\n\tfrom ") + "\n"
  end
 
  def self.parse_trace(trace)
    out = []
    trace.each_with_index do |line,i|
      if line =~ /{(.*)}(.*)/
        out << (script_names[$1.to_i] + $2)
      elsif line.start_with?(':1:')
        break
      else
        out << line
      end
    end
    out
  end
 
  def trace_me
    begin
      raise
    rescue => exception
      puts trace = Error_Handler.do_backtrace(exception)
    end
  end
 
end

alias rgss_main_without_rescue rgss_main

def rgss_main(&block)
  begin
    rgss_main_without_rescue do
      begin
        block.call
      rescue SystemExit
        exit
      rescue Exception => error
        trace = Error_Handler.do_backtrace(error)
        print(trace)
        raise(error.class, trace, [error.backtrace.first])
      end
    end
  end

end

Hope it's helpful!


RE: Error reporting extension! - kyonides - 03-16-2026

Thinking Just my 5 cents here. Did you know that the $RGSS_SCRIPTS variable already contains the scripts data?
I mean, there's no need to load the Scripts.rvdata2 file or the equivalent in RMXP and RMVX. You would just need to extract the script's actual code from each array slot like you already do it in line 10.


RE: Error reporting extension! - Kayzee - 03-16-2026

I didn't know! :o

Edit: Wonder if I could make it compatible with vx and xp actually... don't think rgss_main exists on xp and might not in vx either and overwriting main is a pain...