Leibniz
1
I try to use the DimensionMismatch excpetion https://docs.julialang.org/en/v1/base/base/#Base.DimensionMismatch
throw(DimensionMismatch(["\n some message \n"]))
gives
MethodError: Cannot
convert an object of type Vector{String} to an object of type String
I think the error message should not be a vector. Is this an error in the docs? How can I help with fixing this?
Sukera
2
The docstring is
DimensionMismatch([msg])
The braces []
signify that msg
is optional - it does not mean that you need to pass an array.
For example, you can use either of these:
julia> throw(DimensionMismatch())
ERROR: DimensionMismatch:
Stacktrace:
[1] top-level scope
@ REPL[1]:1
julia> throw(DimensionMismatch("my message"))
ERROR: DimensionMismatch: my message
Stacktrace:
[1] top-level scope
@ REPL[2]:1
though the second version is clearly more helpful/informative once a user encounters it.
4 Likes