[前][次][番号順一覧][スレッド一覧]

ruby-changes:58969

From: Hiroshi <ko1@a...>
Date: Sat, 30 Nov 2019 10:29:55 +0900 (JST)
Subject: [ruby-changes:58969] 9b950310be (master): raise method accepts 3 argument with exception class

https://git.ruby-lang.org/ruby.git/commit/?id=9b950310be

From 9b950310be874753935a6ef4e8f94b3686f70540 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 29 Nov 2019 16:35:51 +0900
Subject: raise method accepts 3 argument with exception class


diff --git a/lib/matrix.rb b/lib/matrix.rb
index 0f4e1b2..5084de2 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -28,14 +28,14 @@ module ExceptionForMatrix # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L28
   end
 
   class ErrOperationNotDefined < StandardError
-    def initialize(op, sc, oc)
-      super("Operation(#{op}) can\\'t be defined: #{sc} op #{oc}")
+    def initialize(vals)
+      super("Operation(#{vals[0]}) can\\'t be defined: #{vals[1]} op #{vals[2]}")
     end
   end
 
   class ErrOperationNotImplemented < StandardError
-    def initialize(op, sc, oc)
-      super("Sorry, Operation(#{op}) not implemented: #{sc} op #{oc}")
+    def initialize(vals)
+      super("Sorry, Operation(#{vals[0]}) not implemented: #{vals[1]} op #{vals[2]}")
     end
   end
 end
@@ -1066,7 +1066,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1066
   def +(m)
     case m
     when Numeric
-      raise ErrOperationNotDefined, "+", self.class, m.class
+      raise ErrOperationNotDefined, ["+", self.class, m.class]
     when Vector
       m = self.class.column_vector(m)
     when Matrix
@@ -1093,7 +1093,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1093
   def -(m)
     case m
     when Numeric
-      raise ErrOperationNotDefined, "-", self.class, m.class
+      raise ErrOperationNotDefined, ["-", self.class, m.class]
     when Vector
       m = self.class.column_vector(m)
     when Matrix
@@ -1226,7 +1226,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1226
       v, d, v_inv = eigensystem
       v * self.class.diagonal(*d.each(:diagonal).map{|e| e ** other}) * v_inv
     else
-      raise ErrOperationNotDefined, "**", self.class, other.class
+      raise ErrOperationNotDefined, ["**", self.class, other.class]
     end
   end
 
@@ -2129,7 +2129,7 @@ class Vector https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L2129
     when Matrix
       Matrix.column_vector(self) * x
     when Vector
-      raise ErrOperationNotDefined, "*", self.class, x.class
+      raise ErrOperationNotDefined, ["*", self.class, x.class]
     else
       apply_through_coercion(x, __method__)
     end
@@ -2180,7 +2180,7 @@ class Vector https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L2180
       els = @elements.collect{|e| e / x}
       self.class.elements(els, false)
     when Matrix, Vector
-      raise ErrOperationNotDefined, "/", self.class, x.class
+      raise ErrOperationNotDefined, ["/", self.class, x.class]
     else
       apply_through_coercion(x, __method__)
     end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]