8 hours ago
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!
Hope it's helpful!
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
endHope it's helpful!


Just my 5 cents here. Did you know that the $RGSS_SCRIPTS variable already contains the scripts data?![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
