Error reporting extension!
#1
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!
Reply


Messages In This Thread
Error reporting extension! - by Kayzee - 3 hours ago

Possibly Related Threads…
Thread Author Replies Views Last Post
   File Missing Error Preventer xnadvance 0 1,669 05-31-2011, 06:04 AM
Last Post: xnadvance
   Error Log PK8 0 1,835 04-03-2009, 01:31 AM
Last Post: PK8



Users browsing this thread: 1 Guest(s)