Skip to content
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

Improve stacktrace of errors thrown from within a callback #233

Merged
merged 2 commits into from
May 15, 2024

Conversation

odow
Copy link
Member

@odow odow commented May 15, 2024

Closes #232

Now gives:

julia> using GLPK; import MathOptInterface as MOI

julia> model = GLPK.Optimizer()
A GLPK model

julia> x = MOI.add_variable(model)
MOI.VariableIndex(1)

julia> MOI.add_constraint(model, x, MOI.ZeroOne())
MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.ZeroOne}(1)

julia> my_callback(args...) = error("FooBar")
my_callback (generic function with 1 method)

julia> MOI.set(model, GLPK.CallbackFunction(), my_callback)

julia> MOI.optimize!(model)
ERROR: FooBar
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] my_callback(args::GLPK.CallbackData)
    @ Main ./REPL[5]:1
  [3] (::GLPK.var"#17#18"{GLPK.Optimizer, typeof(my_callback)})(cb_data::GLPK.CallbackData)
    @ GLPK ~/.julia/dev/GLPK/src/MOI_wrapper/MOI_callbacks.jl:31
  [4] _internal_callback(tree::Ptr{Nothing}, info::Ptr{Nothing})
    @ GLPK ~/.julia/dev/GLPK/src/MOI_wrapper/MOI_wrapper.jl:232
  [5] glp_intopt
    @ ~/.julia/dev/GLPK/src/gen/libglpk_api.jl:342 [inlined]
  [6] _solve_mip_problem(model::GLPK.Optimizer)
    @ GLPK ~/.julia/dev/GLPK/src/MOI_wrapper/MOI_wrapper.jl:1399
  [7] optimize!(model::GLPK.Optimizer)
    @ GLPK ~/.julia/dev/GLPK/src/MOI_wrapper/MOI_wrapper.jl:1448

Copy link

codecov bot commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.74%. Comparing base (596b3a8) to head (5911b02).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
+ Coverage   85.71%   85.74%   +0.02%     
==========================================
  Files           8        8              
  Lines        1911     1915       +4     
==========================================
+ Hits         1638     1642       +4     
  Misses        273      273              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@odow odow merged commit c7ff4d6 into master May 15, 2024
10 checks passed
@odow odow deleted the od/fix-stacktrace branch May 15, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Uninformative stacktrace when bug from the cut callback
1 participant