@@ -90,15 +90,44 @@ function Base.showerror(io::IO, e::ErrorConstrDimMismatch)
9090end
9191
9292struct InfiniteDimensionError <: Exception
93+ msg:: String
9394 check_available:: Bool
94- InfiniteDimensionError (; check_available:: Bool = false ) = new (check_available)
95+
96+ @doc """
97+ InfiniteDimensionError(msg; check_available = false)
98+
99+ A computation could not be carried out because of something being
100+ infinite-dimensional. `msg` is a descriptive error message.
101+
102+ Set `check_available` to `true` to add the line "You may check finiteness with
103+ `is_finite_dimensional_vector_space`" to the error message.
104+
105+ # Examples
106+
107+ ```jldoctest
108+ julia> throw(InfiniteDimensionError(check_available=true))
109+ ERROR: InfiniteDimensionError
110+ You may check finiteness with `is_finite_dimensional_vector_space`
111+ [...]
112+
113+ julia> throw(InfiniteDimensionError("The vector space is infinite-dimensional"))
114+ ERROR: InfiniteDimensionError: The vector space is infinite-dimensional
115+ [...]
116+ ```
117+ """
118+ function InfiniteDimensionError (msg:: String = " " ; check_available:: Bool = false )
119+ return new (msg, check_available)
120+ end
95121end
96122
97123function Base. showerror (io:: IO , e:: InfiniteDimensionError )
124+ m = " InfiniteDimensionError"
125+ if ! isempty (e. msg)
126+ m *= " : "
127+ m *= e. msg
128+ end
129+ println (io, m)
98130 if e. check_available
99- println (io, " Infinite-dimensional vector space" )
100- print (io, " You may check finiteness with `is_finite_dimensional_vector_space`" )
101- else
102- println (io, " Infinite-dimensional vector space" )
131+ println (io, " You may check finiteness with `is_finite_dimensional_vector_space`" )
103132 end
104133end
0 commit comments