]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
script plugin: report_error() method
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 15 Apr 2008 13:01:26 +0000 (15:01 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 15 Apr 2008 13:01:26 +0000 (15:01 +0200)
data/rbot/plugins/script.rb

index 8a3e1e847a0876416906a8b86186ba9a91c95e6a..2d730fe92c426cb8cd012a3d03ae0db9d0ba35e5 100644 (file)
@@ -41,6 +41,12 @@ class ScriptPlugin < Plugin
     end
   end
 
+  def report_error(m, name, e)
+    # ed = e.backtrace.unshift(e.inspect).join(' ')
+    ed = e.inspect
+    m.reply( "Script '#{name}' crapped out :( #{ed}" )
+  end
+
 
   def listen( m )
     name = m.message.split.first
@@ -60,8 +66,7 @@ class ScriptPlugin < Plugin
         begin
           eval( code )
         rescue Exception => e
-          m.reply( "Script '#{name}' crapped out :(" )
-          m.reply( e.inspect )
+          report_error(m, name, e)
         end
       }
       m.replied = true
@@ -76,8 +81,7 @@ class ScriptPlugin < Plugin
       begin
         eval( code )
       rescue Exception => e
-        m.reply( "Script '#{name}' crapped out :(" )
-        m.reply( e.inspect )
+        report_error(m, code, e)
       end
     }
     m.replied = true
@@ -91,8 +95,7 @@ class ScriptPlugin < Plugin
       begin
         m.reply eval( code ).to_s
       rescue Exception => e
-        m.reply( "Script '#{name}' crapped out :(" )
-        m.reply( e.inspect )
+        report_error(m, code, e)
       end
     }
     m.replied = true