Skip to content

Commit d783918

Browse files
add verbose print error messages to specialized excpetions
Requires SciML/SciMLBase.jl#400
1 parent efccf8d commit d783918

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/solve.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ function Base.showerror(io::IO, e::CommonKwargError)
112112
print(io, "Unrecognized keyword arguments: ")
113113
printstyled(io, unrecognized; bold = true, color = :red)
114114
print(io, "\n\n")
115+
println(io, SciMLBase.VERBOSE_MSG)
115116
end
116117

117118
@enum KeywordArgError KeywordArgWarn KeywordArgSilent
@@ -137,6 +138,7 @@ struct IncompatibleInitialConditionError <: Exception end
137138

138139
function Base.showerror(io::IO, e::IncompatibleInitialConditionError)
139140
print(io, INCOMPATIBLE_U0_MESSAGE)
141+
println(io, SciMLBase.VERBOSE_MSG)
140142
end
141143

142144
const NO_DEFAULT_ALGORITHM_MESSAGE = """
@@ -153,6 +155,7 @@ struct NoDefaultAlgorithmError <: Exception end
153155

154156
function Base.showerror(io::IO, e::NoDefaultAlgorithmError)
155157
print(io, NO_DEFAULT_ALGORITHM_MESSAGE)
158+
println(io, SciMLBase.VERBOSE_MSG)
156159
end
157160

158161
const NO_TSPAN_MESSAGE = """
@@ -163,6 +166,7 @@ struct NoTspanError <: Exception end
163166

164167
function Base.showerror(io::IO, e::NoTspanError)
165168
print(io, NO_TSPAN_MESSAGE)
169+
println(io, SciMLBase.VERBOSE_MSG)
166170
end
167171

168172
const NON_SOLVER_MESSAGE = """
@@ -180,6 +184,7 @@ struct NonSolverError <: Exception end
180184

181185
function Base.showerror(io::IO, e::NonSolverError)
182186
print(io, NON_SOLVER_MESSAGE)
187+
println(io, SciMLBase.VERBOSE_MSG)
183188
end
184189

185190
const PROBSOLVER_PAIRING_MESSAGE = """
@@ -200,6 +205,7 @@ function Base.showerror(io::IO, e::ProblemSolverPairingError)
200205
println(io, "Solver type: $(SciMLBase.__parameterless_type(typeof(e.alg)))")
201206
println(io,
202207
"Problem types compatible with the chosen solver: $(compatible_problem_types(e.prob,e.alg))")
208+
println(io, SciMLBase.VERBOSE_MSG)
203209
end
204210

205211
function compatible_problem_types(prob, alg)
@@ -240,6 +246,7 @@ struct DirectAutodiffError <: Exception end
240246

241247
function Base.showerror(io::IO, e::DirectAutodiffError)
242248
println(io, DIRECT_AUTODIFF_INCOMPATABILITY_MESSAGE)
249+
println(io, SciMLBase.VERBOSE_MSG)
243250
end
244251

245252
const NONCONCRETE_ELTYPE_MESSAGE = """
@@ -273,6 +280,7 @@ end
273280
function Base.showerror(io::IO, e::NonConcreteEltypeError)
274281
print(io, NONCONCRETE_ELTYPE_MESSAGE)
275282
print(io, e.eltype)
283+
println(io, SciMLBase.VERBOSE_MSG)
276284
end
277285

278286
const GENERIC_NUMBER_TYPE_ERROR_MESSAGE = """
@@ -298,6 +306,7 @@ function Base.showerror(io::IO, e::GenericNumberTypeError)
298306
println(io, "Solver: $(e.alg)")
299307
println(io, "u0 type: $(e.uType)")
300308
print(io, "Timespan type: $(e.tType)")
309+
println(io, SciMLBase.VERBOSE_MSG)
301310
end
302311

303312
const COMPLEX_SUPPORT_ERROR_MESSAGE = """
@@ -316,6 +325,7 @@ end
316325
function Base.showerror(io::IO, e::ComplexSupportError)
317326
println(io, COMPLEX_SUPPORT_ERROR_MESSAGE)
318327
println(io, "Solver: $(e.alg)")
328+
println(io, SciMLBase.VERBOSE_MSG)
319329
end
320330

321331
const COMPLEX_TSPAN_ERROR_MESSAGE = """
@@ -330,6 +340,7 @@ struct ComplexTspanError <: Exception end
330340

331341
function Base.showerror(io::IO, e::ComplexTspanError)
332342
println(io, COMPLEX_TSPAN_ERROR_MESSAGE)
343+
println(io, SciMLBase.VERBOSE_MSG)
333344
end
334345

335346
const TUPLE_STATE_ERROR_MESSAGE = """
@@ -367,6 +378,7 @@ struct TupleStateError <: Exception end
367378

368379
function Base.showerror(io::IO, e::TupleStateError)
369380
println(io, TUPLE_STATE_ERROR_MESSAGE)
381+
println(io, SciMLBase.VERBOSE_MSG)
370382
end
371383

372384
const MASS_MATRIX_ERROR_MESSAGE = """
@@ -387,6 +399,7 @@ function Base.showerror(io::IO, e::IncompatibleMassMatrixError)
387399
println(io, e.sz)
388400
print(io, "length(u0): ")
389401
println(e.len)
402+
println(io, SciMLBase.VERBOSE_MSG)
390403
end
391404

392405
function init_call(_prob, args...; merge_callbacks = true, kwargshandle = KeywordArgWarn,
@@ -1386,6 +1399,7 @@ struct AdjointNotFoundError <: Exception end
13861399

13871400
function Base.showerror(io::IO, e::AdjointNotFoundError)
13881401
print(io, ADJOINT_NOT_FOUND_MESSAGE)
1402+
println(io, SciMLBase.VERBOSE_MSG)
13891403
end
13901404

13911405
function _concrete_solve_adjoint(args...; kwargs...)
@@ -1402,6 +1416,7 @@ struct ForwardSensitivityNotFoundError <: Exception end
14021416

14031417
function Base.showerror(io::IO, e::ForwardSensitivityNotFoundError)
14041418
print(io, FORWARD_SENSITIVITY_NOT_FOUND_MESSAGE)
1419+
println(io, SciMLBase.VERBOSE_MSG)
14051420
end
14061421

14071422
function _concrete_solve_forward(args...; kwargs...)

0 commit comments

Comments
 (0)