lpil / pgo

🐘 Use PostgreSQL databases with PGO
https://hexdocs.pm/gleam_pgo/
Apache License 2.0
136 stars 12 forks source link

Add query_error_to_string #31

Open sporto opened 4 months ago

sporto commented 4 months ago

I would like to have a quick way to convert the query errors to a string

fn find_user(email: String) ->  Result(User, String) {
  ...

  use returned <- result.try(
    pgo.execute(select_sql, db, [pgo.text(email)], return_type)
    |> result.map_error(pgo.query_error_to_string),
  )

  ...
}

What do you think? Would be nice if dynamic could have this too