Skip to content

Commit 402e945

Browse files
committed
improve spacemismatch error printing
1 parent 9f2b662 commit 402e945

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/TensorKit.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,11 @@ struct SpaceMismatch{S <: Union{Nothing, AbstractString}} <: TensorException
176176
message::S
177177
end
178178
SpaceMismatch() = SpaceMismatch{Nothing}(nothing)
179-
Base.showerror(io::IO, ::SpaceMismatch{Nothing}) = print(io, "SpaceMismatch()")
180-
Base.showerror(io::IO, e::SpaceMismatch) = print(io, "SpaceMismatch(\"", e.message, "\")")
179+
function Base.showerror(io::IO, err::SpaceMismatch)
180+
print(io, "SpaceMismatch: ")
181+
isnothing(err.message) || print(io, err.message)
182+
return nothing
183+
end
181184

182185
# Exception type for all errors related to invalid tensor index specification.
183186
struct IndexError{S <: Union{Nothing, AbstractString}} <: TensorException

0 commit comments

Comments
 (0)