@@ -413,6 +413,73 @@ function test_exception_display()
413413 Test. @test contains (output, " Suggestion:" )
414414 Test. @test contains (output, " Increase max iterations" )
415415 end
416+
417+ Test. @testset " IncorrectArgument - got without expected" begin
418+ io = IOBuffer ()
419+ e = Exceptions. IncorrectArgument (" wrong value" , got= " bad_value" )
420+ Test. @test_nowarn showerror (io, e)
421+ output = String (take! (io))
422+
423+ Test. @test contains (output, " Got:" )
424+ Test. @test contains (output, " bad_value" )
425+ Test. @test ! contains (output, " Expected:" )
426+ end
427+
428+ Test. @testset " AmbiguousDescription - diagnostic rendering" begin
429+ # "empty catalog" branch
430+ io = IOBuffer ()
431+ e = Exceptions. AmbiguousDescription (
432+ (:a ,); diagnostic= " empty catalog"
433+ )
434+ Test. @test_nowarn showerror (io, e)
435+ output = String (take! (io))
436+ Test. @test contains (output, " Diagnostic:" )
437+ Test. @test contains (output, " Empty catalog" )
438+
439+ # "unknown symbols" branch
440+ io = IOBuffer ()
441+ e = Exceptions. AmbiguousDescription (
442+ (:z ,); diagnostic= " unknown symbols"
443+ )
444+ Test. @test_nowarn showerror (io, e)
445+ output = String (take! (io))
446+ Test. @test contains (output, " Diagnostic:" )
447+ Test. @test contains (output, " Unknown symbols" )
448+
449+ # "no complete match" branch
450+ io = IOBuffer ()
451+ e = Exceptions. AmbiguousDescription (
452+ (:a , :z ); diagnostic= " no complete match"
453+ )
454+ Test. @test_nowarn showerror (io, e)
455+ output = String (take! (io))
456+ Test. @test contains (output, " Diagnostic:" )
457+ Test. @test contains (output, " No complete match" )
458+
459+ # else branch — arbitrary diagnostic value
460+ io = IOBuffer ()
461+ e = Exceptions. AmbiguousDescription (
462+ (:a ,); diagnostic= " custom diagnostic"
463+ )
464+ Test. @test_nowarn showerror (io, e)
465+ output = String (take! (io))
466+ Test. @test contains (output, " Diagnostic:" )
467+ Test. @test contains (output, " custom diagnostic" )
468+ end
469+
470+ Test. @testset " AmbiguousDescription - closest-matches inline suggestion" begin
471+ io = IOBuffer ()
472+ e = Exceptions. AmbiguousDescription (
473+ (:b , :f );
474+ candidates= [" (:a, :b, :c)" , " (:a, :d, :e)" , " (:x, :y, :z)" ],
475+ suggestion= " Try one of the closest matches:" ,
476+ )
477+ Test. @test_nowarn showerror (io, e)
478+ output = String (take! (io))
479+
480+ Test. @test contains (output, " closest matches" )
481+ Test. @test contains (output, " (:a, :b, :c)" )
482+ end
416483 end
417484end
418485
0 commit comments