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

execute and async_execute exception handling difference #279

Open
krynju opened this issue Aug 24, 2023 · 0 comments
Open

execute and async_execute exception handling difference #279

krynju opened this issue Aug 24, 2023 · 0 comments

Comments

@krynju
Copy link
Contributor

krynju commented Aug 24, 2023

So when using async_execute you basically need to unwrap TaskFailedException, which contains a CompositeException, which contains one (or many?) exceptions.
With execute it's much simpler

Should we make it more similiar?

julia> LibPQ.execute(conn, "select from x")
[error | LibPQ]: UndefinedTable: ERROR:  relation "x" does not exist
LINE 1: select from x
                    ^
ERROR: UndefinedTable: ERROR:  relation "x" does not exist
LINE 1: select from x
                    ^
Stacktrace:
 [1] error(logger::Memento.Logger, exc::LibPQ.Errors.PQResultError{LibPQ.Errors.C42, LibPQ.Errors.E42P01})
   @ Memento ~/.julia/packages/Memento/xnHxE/src/loggers.jl:463
 [2] handle_result(jl_result::LibPQ.Result{false}; throw_error::Bool)
   @ LibPQ ~/.julia/packages/LibPQ/1oHrl/src/results.jl:238
 [3] _multi_execute(jl_conn::LibPQ.Connection, query::String; throw_error::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ LibPQ ~/.julia/packages/LibPQ/1oHrl/src/results.jl:305
 [4] _multi_execute
   @ ~/.julia/packages/LibPQ/1oHrl/src/results.jl:301 [inlined]
 [5] #execute#51
   @ ~/.julia/packages/LibPQ/1oHrl/src/results.jl:294 [inlined]
 [6] execute(conn::LibPQ.Connection, query::String)
   @ LibPQ ~/.julia/packages/LibPQ/1oHrl/src/results.jl:291
 [7] top-level scope
   @ REPL[4]:1

julia> LibPQ.async_execute(conn, "select from x") |> fetch
[error | LibPQ]: UndefinedTable: ERROR:  relation "x" does not exist
LINE 1: select from x
                    ^
ERROR: TaskFailedException
Stacktrace:
 [1] wait
   @ ./task.jl:322 [inlined]
 [2] fetch
   @ ./task.jl:337 [inlined]
 [3] fetch
   @ ~/.julia/packages/LibPQ/1oHrl/src/asyncresults.jl:183 [inlined]
 [4] |>(x::LibPQ.AsyncResult{false}, f::typeof(fetch))
   @ Base ./operators.jl:858
 [5] top-level scope
   @ REPL[5]:1

    nested task error: UndefinedTable: ERROR:  relation "x" does not exist
    LINE 1: select from x
                        ^
    Stacktrace:
     [1] handle_result(async_result::LibPQ.AsyncResult{false}; throw_error::Bool)
       @ LibPQ ~/.julia/packages/LibPQ/1oHrl/src/asyncresults.jl:74
     [2] (::LibPQ.var"#106#108"{Bool, LibPQ.var"#98#99"{String}, LibPQ.Connection, LibPQ.AsyncResult{false}})()
       @ LibPQ ~/.julia/packages/LibPQ/1oHrl/src/asyncresults.jl:280
     [3] lock(f::LibPQ.var"#106#108"{Bool, LibPQ.var"#98#99"{String}, LibPQ.Connection, LibPQ.AsyncResult{false}}, conn::LibPQ.Connection)
       @ LibPQ ~/.julia/packages/LibPQ/1oHrl/src/connections.jl:337
     [4] (::LibPQ.var"#105#107"{Bool, LibPQ.var"#98#99"{String}, LibPQ.Connection, LibPQ.AsyncResult{false}})()
       @ LibPQ ./task.jl:417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant