Commit db4407e

mo <mo.khan@gmail.com>
2018-05-19 17:40:22
catch specific error and add general error handler.
1 parent 13508c3
Changed files (1)
lib
lib/del/tron.rb
@@ -17,6 +17,8 @@ module Del
         whoami: -> { whoami(request) },
         whois: -> { JSON.generate(whois(request['q'])) }
       }[request['command'].to_sym]&.call || 'Unknown'
+    rescue StandardError => error
+      error.message
     end
 
     private
@@ -41,8 +43,8 @@ module Del
     def change_status(request)
       robot.public_send("#{request['status'].downcase}!", request['message'])
       'Done!'
-    rescue
-      "Error: Invalid status"
+    rescue NoMethodError
+      'Error: Invalid status'
     end
   end
 end