Skip to content

Commit 41f5d4b

Browse files
author
Will Kimmerer
committed
errors to exceptions
1 parent b8ca548 commit 41f5d4b

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

src/descriptors.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function Base.getproperty(d::Descriptor, s::Symbol)
3535
#elseif s == :sort
3636
#f = libgb.GxB_SORT
3737
else
38-
error("type Descriptor has no field $s")
38+
throw(UndefRefError())
3939
end
4040
return libgb.GxB_Descriptor_get(d, f)
4141
end
@@ -60,7 +60,7 @@ function Base.setproperty!(d::Descriptor, s::Symbol, x)
6060
#elseif s == :sort
6161
#f = libgb.GxB_SORT
6262
else
63-
error("type Descriptor has no field $s")
63+
throw(UndefRefError())
6464
end
6565
libgb.GrB_Descriptor_set(d, f, x)
6666
end

src/gbtypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ function toGBType(x)
129129
elseif x == ComplexF64
130130
return FC64
131131
else
132-
error("Not a valid GrB data type")
132+
throw(ArgumentError("Not a valid GrB data type"))
133133
end
134134
end

src/libutils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function suffix(T)
2727
elseif T == ComplexF64
2828
return "FC64"
2929
else
30-
error("Not a valid GrB data type")
30+
throw(ArgumentError("Not a valid GrB data type"))
3131
end
3232
end
3333

@@ -59,7 +59,7 @@ function towrappertype(T)
5959
elseif T == ComplexF64
6060
return :GxB_FC64_t
6161
else
62-
error("Not a valid GrB data type")
62+
throw(ArgumentError("Not a valid GrB data type"))
6363
end
6464
end
6565

src/matrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function GBMatrix(I::Vector, J::Vector, x::T;
4141
end
4242

4343
function build(A::GBMatrix{T}, I::Vector, J::Vector, x::T) where {T}
44-
nnz(A) == 0 || error("Cannot build matrix with existing elements")
44+
nnz(A) == 0 || throw(libgb.OutputNotEmptyError("Cannot build matrix with existing elements"))
4545
length(I) == length(J) || DimensionMismatch("I, J and X must have the same length")
4646
x = GBScalar(x)
4747

@@ -116,7 +116,7 @@ for T ∈ valid_vec
116116
dup = BinaryOps.PLUS
117117
)
118118
dup = getoperator(dup, $T)
119-
nnz(A) == 0 || error("Cannot build matrix with existing elements")
119+
nnz(A) == 0 || throw(libgb.OutputNotEmptyError("Cannot build matrix with existing elements"))
120120
length(X) == length(I) == length(J) ||
121121
DimensionMismatch("I, J and X must have the same length")
122122
libgb.$func(

src/operators/binaryops.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function BinaryOp(
155155
)
156156
op = BinaryOp(name)
157157
length(ztype) == length(xtype) == length(ytype) ||
158-
error("Lengths of ztype, xtype, and ytype must match")
158+
throw(DimensionMismatch("Lengths of ztype, xtype, and ytype must match"))
159159
for i 1:length(ztype)
160160
_addbinaryop(op, fn, toGBType(ztype[i]), toGBType(xtype[i]), toGBType(ytype[i]))
161161
end

src/operators/unaryops.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ end
136136
#Vector of xtypes and ztypes, add a GrB_UnaryOp for each.
137137
function UnaryOp(name::String, fn::Function, ztype::Vector{DataType}, xtype::Vector{DataType})
138138
op = UnaryOp(name)
139-
length(ztype) == length(xtype) || error("Lengths of ztype and xtype must match.")
139+
length(ztype) == length(xtype) || throw(DimensionMismatch("Lengths of ztype and xtype must match."))
140140
for i 1:length(ztype)
141141
_addunaryop(op, fn, toGBType(ztype[i]), toGBType(xtype[i]))
142142
end

src/vector.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function GBVector(I::Vector, x::T;
3535
end
3636

3737
function build(A::GBVector{T}, I::Vector, x::T) where {T}
38-
nnz(A) == 0 || error("Cannot build matrix with existing elements")
38+
nnz(A) == 0 || throw(libgb.OutputNotEmptyError("Cannot build vector with existing elements"))
3939
x = GBScalar(x)
4040

4141
libgb.GxB_Vector_build_Scalar(
@@ -113,7 +113,7 @@ for T ∈ valid_vec
113113
func = Symbol(prefix, :_Vector_build_, suffix(T))
114114
@eval begin
115115
function build(v::GBVector{$T}, I::Vector, X::Vector{$T}; dup = BinaryOps.PLUS)
116-
nnz(v) == 0 || error("Cannot build vector with existing elements")
116+
nnz(v) == 0 || throw(libgb.OutputNotEmptyError("Cannot build vector with existing elements"))
117117
length(X) == length(I) || DimensionMismatch("I and X must have the same length")
118118
libgb.$func(v, Vector{libgb.GrB_Index}(I), X, length(X), dup[$T])
119119
end

0 commit comments

Comments
 (0)