raise method accepts 3 argument with exception class

This commit is contained in:
Hiroshi SHIBATA 2019-11-29 16:35:51 +09:00 коммит произвёл SHIBATA Hiroshi
Родитель f47f2076fe
Коммит 9b950310be
1 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -28,14 +28,14 @@ module ExceptionForMatrix # :nodoc:
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
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
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
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
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
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