Skip to content

Commit 8c7fe68

Browse files
committed
Detailed showerror for SingularException
1 parent 2a1696a commit 8c7fe68

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/exceptions.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ struct SingularException <: Exception
2828
info::BlasInt
2929
end
3030

31+
function Base.showerror(io::IO, ex::SingularException)
32+
print(io, "SingularException: matrix is singular; factorization failed. Zero eigenvalue found at index ", ex.info)
33+
end
34+
3135
"""
3236
PosDefException
3337

test/dense.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,4 +1366,9 @@ end
13661366
@test !any(LinearAlgebra.getstructure(A))
13671367
end
13681368

1369+
@testset "SingularException show" begin
1370+
A = diagm(0=> [1, 0])
1371+
@test_throws "matrix is singular; factorization failed" inv(A)
1372+
end
1373+
13691374
end # module TestDense

0 commit comments

Comments
 (0)