perrycate / tournamap

Website to visualize Smash Ultimate tournaments near you
https://tournamap.gg
GNU General Public License v3.0
9 stars 6 forks source link

Better expose errors during fetching. #54

Closed perrycate closed 1 year ago

perrycate commented 1 year ago

Right now, if fetching the data from start.gg goes anything less than perfectly, we do nothing to expose the error (for example by writing it to stderr). For example, if the auth token is invalid, this is all we write to stderr at the moment:

** (BadMapError) expected a map, got: nil
    (elixir 1.14.0) lib/map.ex:534: Map.get(nil, "tournaments", nil)
    (tournamap 0.1.0) lib/util.ex:75: Util.get_tourney_page/2
    (elixir 1.14.0) lib/enum.ex:1662: anonymous fn/3 in Enum.map/2
    (elixir 1.14.0) lib/enum.ex:4299: Enum.reduce_range/5
    (elixir 1.14.0) lib/enum.ex:2472: Enum.map/2
    (tournamap 0.1.0) lib/util.ex:21: Util.get_all_tourneys/0
    (tournamap 0.1.0) lib/util.ex:6: Util.update_tourneys/1
    nofile:1: (file)

We should instead look for an error in the response from start.gg and log it.

ajistrying commented 1 year ago

Do we want to do any fancy logging here or just IO.puts whatever comes out? Open to any option really, clear errors during fetching will be really valuable.

perrycate commented 1 year ago

I'm not super familiar with the logging options elixir gives us out of the box, so if you have any suggestions I'd love to hear them. Otherwise let's just do IO.puts to stderr - it's not like we have comprehensive logging elsewhere anyway. :man_shrugging:

perrycate commented 1 year ago

Oh and we should exit when we do so as well, so that it's considered a failure by future automation :eyes:

ajistrying commented 1 year ago

Sounds good, I'll spend a little time looking for a solution.

ajistrying commented 1 year ago

PR here with initial attempt

perrycate commented 1 year ago

Fixed by #57. Thanks, @ajistrying !