From a837090bd2c0192234a3608ac304a097cf98a390 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Wed, 30 Apr 2014 12:22:27 -0700 Subject: [PATCH] Add better error messages for dimension mismatches in promote_array --- base/operators.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/operators.jl b/base/operators.jl index dfe1243b5158b..e0ae5275a435d 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -156,14 +156,14 @@ copy(x::Union(Symbol,Number,String,Function,Tuple,LambdaStaticData, function promote_shape(a::(Int,), b::(Int,)) if a[1] != b[1] - error("dimensions must match") + throw(DimensionMismatch("Cannot promote dimensions $(a) to $(b)")) end return a end function promote_shape(a::(Int,Int), b::(Int,)) if a[1] != b[1] || a[2] != 1 - error("dimensions must match") + throw(DimensionMismatch("Cannot promote dimensions $(a) to $(b)")) end return a end @@ -172,7 +172,7 @@ promote_shape(a::(Int,), b::(Int,Int)) = promote_shape(b, a) function promote_shape(a::(Int, Int), b::(Int, Int)) if a[1] != b[1] || a[2] != b[2] - error("dimensions must match") + throw(DimensionMismatch("Cannot promote dimensions $(a) to $(b)")) end return a end @@ -183,12 +183,12 @@ function promote_shape(a::Dims, b::Dims) end for i=1:length(b) if a[i] != b[i] - error("dimensions must match") + throw(DimensionMismatch("Cannot promote dimensions $(a) to $(b)")) end end for i=length(b)+1:length(a) if a[i] != 1 - error("dimensions must match") + throw(DimensionMismatch("Cannot promote dimensions $(a) to $(b)")) end end return a