diff --git a/src/exceptions.jl b/src/exceptions.jl index 7791b1dd..c346ce08 100644 --- a/src/exceptions.jl +++ b/src/exceptions.jl @@ -28,6 +28,10 @@ struct SingularException <: Exception info::BlasInt end +function Base.showerror(io::IO, ex::SingularException) + print(io, "SingularException: matrix is singular; factorization failed. Zero pivot found at index ", ex.info) +end + """ PosDefException diff --git a/test/dense.jl b/test/dense.jl index 1f953ea9..88eccfa6 100644 --- a/test/dense.jl +++ b/test/dense.jl @@ -1366,4 +1366,9 @@ end @test !any(LinearAlgebra.getstructure(A)) end +@testset "SingularException show" begin + A = diagm(0=> [1, 0]) + @test_throws "matrix is singular; factorization failed" inv(A) +end + end # module TestDense