08-13-2013, 02:47 PM
Do you really need that backtracing script?
I have one in my project, i really don't know the scripter name (sorry dude), but the script helps me greatly: it shows the backtrace, the script names, the line and method called. And i'm writing a CMS \ CBS in my game.
Hope it helps.
To install it, just change this part of Main script...
For this.
The backtrace is saved in the file ErrorLog.rxdata in the project's root directory. Its a stream of characters, so any text editor can read it's data (Notepad, Wordpad, Notepad++, Sublime Text, etc).
I have one in my project, i really don't know the scripter name (sorry dude), but the script helps me greatly: it shows the backtrace, the script names, the line and method called. And i'm writing a CMS \ CBS in my game.
Hope it helps.
To install it, just change this part of Main script...
Code:
rescue Errno::ENOENT
# Aqui, definimos a mensagem padrão para Errno::ENOENT
# Quando não é possível abrir um arquivo, a mensagem é exibida
filename = $!.message.sub("Arquivo não encontrado - ", "")
print("O Arquivo #{filename} não foi encontrado.")
end
For this.
Code:
rescue Errno::ENOENT
# Aqui, definimos a mensagem padrão para Errno::ENOENT
# Quando não é possível abrir um arquivo, a mensagem é exibida
filename = $!.message.sub("Arquivo não encontrado - ", "")
print("O Arquivo #{filename} não foi encontrado.")
rescue StandardError => stderr
# Bring message to user that an error has occured
p "Your error message here. See Instructions for more details."
# Optional, when debugging, you will still receive the error message, but in less details.
if $DEBUG
p stderr.message
end
# When?
time = Time.now
time = time.strftime("%a %d %b %Y, %X")
# Write to file
File.open("ErrorLog.rxdata","a+") do |fh|
# Time
fh.puts("Time: #{time}")
# Error type
fh.puts("Error type: #{stderr.class}")
# In which class?
fh.puts("Class: #{$scene.class}")
# Message
fh.puts("Message: #{stderr.message}")
# Where?
fh.puts("at")
for location in stderr.backtrace
# Get the section number
section = location[/(?#Section)(\d)*(:)/]
# Strip off anything but numbers
section_err = section[0, section.length - 1]
script_name = $RGSS_SCRIPTS[section_err.to_i][1]
# Get line number
line_num = location[/(:)(\d)*(\Z|(:))/]
# Strip off anything but line number
#line_num_err = line_num[section_err.length + 1, line_num.length - section_err.length]
# Strip off ":" if any
line_num_err = line_num[1, line_num.length - 1]
line_num_err = line_num_err[/(\d)*/]
# If any, get method name
method = location[/\s\W(\w)*\W/]
# Strip the space
method = method[1, method.length - 1] unless method == nil
# Now construct location string
loc_err = script_name + ", line " + line_num_err +
(method == nil ? "" : ", at " + method)
# Write to file
fh.puts(" #{loc_err}")
end
# Delimiter
fh.puts("--------------------")
end
end
The backtrace is saved in the file ErrorLog.rxdata in the project's root directory. Its a stream of characters, so any text editor can read it's data (Notepad, Wordpad, Notepad++, Sublime Text, etc).