- Joined
- Sep 16, 2012
- Messages
- 453
- Reaction score
- 211
- First Language
- English
- Primarily Uses
- RMMV
In an effort to improve my coding habits and knowledge of Ruby I am learning how to handle errors. While using backtrace in Aptana it shows the offending filename, line number and method. However in RPG maker with the same code the file name part shows what appears to be the script index instead of the name. The RPG maker help file says that backtrace should output like so:
"#{sourcefile}:#{sourceline}:in `#{method}'"I'll use the following script as an example:
This in Aptana outputs:
arg1 must not equal 0 or 0.0C:/Users/Name/Documents/Aptana Studio 3 Workspace/testing/testfile.rb:19:in `run'C:/Users/Name/Documents/Aptana Studio 3 Workspace/testing/testfile.rb:29:in `run2'C:/Users/Name/Documents/Aptana Studio 3 Workspace/testing/testfile.rb:33:in `<main>'In RPG maker it outputs as:
arg1 must not equal 0 or 0.0{0128}:19:in 'run'{0128}:29:in 'run2'{0128}:33:in '<main>'So then how can I use backtrace to output something like:
arg1 must not equal 0 or 0.0Testfile:19:in 'run'Testfile:29:in 'run2'Testfile:33:in '<main>'Thanks for any help on this.
"#{sourcefile}:#{sourceline}:in `#{method}'"I'll use the following script as an example:
class Test def self.run(arg1) num = 5 num /= arg1 raise ZeroDivisionError, "arg1 must not equal 0 or 0.0\n" if arg1 == 0.0 return num rescue ZeroDivisionError => e print e.message e.backtrace.join("\n") endendclass Test2 def self.run2 puts Test.run(0) endendTest2.run2
arg1 must not equal 0 or 0.0C:/Users/Name/Documents/Aptana Studio 3 Workspace/testing/testfile.rb:19:in `run'C:/Users/Name/Documents/Aptana Studio 3 Workspace/testing/testfile.rb:29:in `run2'C:/Users/Name/Documents/Aptana Studio 3 Workspace/testing/testfile.rb:33:in `<main>'In RPG maker it outputs as:
arg1 must not equal 0 or 0.0{0128}:19:in 'run'{0128}:29:in 'run2'{0128}:33:in '<main>'So then how can I use backtrace to output something like:
arg1 must not equal 0 or 0.0Testfile:19:in 'run'Testfile:29:in 'run2'Testfile:33:in '<main>'Thanks for any help on this.
Last edited by a moderator:
