-
Notifications
You must be signed in to change notification settings - Fork 228
Improve error message for initialization failures with troubleshootin… #2637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
67efd02
9c33116
85c7f74
fa97490
a0fe160
a178d70
7bc16b8
fe8409c
8512827
f2925d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,6 +276,29 @@ using Turing | |
@test Turing.Inference.getstepsize(spl, hmc_state) isa Float64 | ||
end | ||
end | ||
|
||
@testset "improved error message for initialization failures" begin | ||
# Model that always fails to initialize | ||
@model function failing_model() | ||
x ~ Normal() | ||
@addlogprob! -Inf | ||
end | ||
|
||
# Test that error message includes troubleshooting link | ||
@test_throws ErrorException sample(failing_model(), NUTS(), 10; progress=false) | ||
|
||
# Verify the error message contains the troubleshooting link | ||
err = try | ||
sample(failing_model(), NUTS(), 10; progress=false) | ||
catch e | ||
e | ||
end | ||
|
||
@test contains( | ||
string(err), | ||
"https://turinglang.org/docs/usage/troubleshooting/#initial-parameters", | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, too, can in fact be done with julia> f() = throw(ErrorException("this is an error message that contains the phrase 'this must be in the error'"))
f (generic function with 1 method)
julia> @test_throws "this must be in the error" f()
Test Passed
Message: "this is an error message that contains the phrase 'this must be in the error'" I'm not sure if you can check for both the substring and the exception type in one call to |
||
end | ||
end | ||
|
||
end |
Uh oh!
There was an error while loading. Please reload this page.