Skip to content

Commit fb895fa

Browse files
committed
Throw ArgumentError
1 parent 42d7afc commit fb895fa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/sparse.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function jacobian_sparsity(f!, y, x, sd::KnownJacobianSparsityDetector)
7171
return sd.jacobian_sparsity
7272
end
7373
function hessian_sparsity(f, x, sd::KnownJacobianSparsityDetector)
74-
error("KnownJacobianSparsityDetector can't be used to compute Hessian sparsity.")
74+
throw(ArgumentError("KnownJacobianSparsityDetector can't be used to compute Hessian sparsity."))
7575
end
7676

7777
"""
@@ -97,10 +97,10 @@ function hessian_sparsity(f, x, sd::KnownHessianSparsityDetector)
9797
end
9898

9999
function jacobian_sparsity(f, x, sd::KnownHessianSparsityDetector)
100-
error("KnownHessianSparsityDetector can't be used to compute Jacobian sparsity.")
100+
throw(ArgumentError("KnownHessianSparsityDetector can't be used to compute Jacobian sparsity."))
101101
end
102102
function jacobian_sparsity(f!, y, x, sd::KnownHessianSparsityDetector)
103-
error("KnownHessianSparsityDetector can't be used to compute Jacobian sparsity.")
103+
throw(ArgumentError("KnownHessianSparsityDetector can't be used to compute Jacobian sparsity."))
104104
end
105105

106106
## Coloring algorithm

test/sparse.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end
8080
nx = length(x)
8181
Href = rand(Bool, nx, nx)
8282
sd = KnownJacobianSparsityDetector(Href)
83-
@test_throws ErrorException hessian_sparsity(f_hess, x, sd)
83+
@test_throws ArgumentError hessian_sparsity(f_hess, x, sd)
8484
end
8585
end
8686
@testset "Exceptions: DimensionMismatch" begin
@@ -112,7 +112,7 @@ end
112112
nx = length(x)
113113
Jref = rand(Bool, 2 * nx, nx)
114114
sd = KnownHessianSparsityDetector(Jref)
115-
@test_throws ErrorException jacobian_sparsity(f, x, sd)
115+
@test_throws ArgumentError jacobian_sparsity(f, x, sd)
116116
end
117117
end
118118
@testset "In-place functions" begin
@@ -121,7 +121,7 @@ end
121121
nx, ny = length(x), length(y)
122122
Jref = rand(Bool, ny, nx)
123123
sd = KnownHessianSparsityDetector(Jref)
124-
@test_throws ErrorException jacobian_sparsity(f_jac!, y, x, sd)
124+
@test_throws ArgumentError jacobian_sparsity(f_jac!, y, x, sd)
125125
end
126126
end
127127
end

0 commit comments

Comments
 (0)