Skip to content

Add missing fields; add missing standard conformances; improve HTTP error reporting and configuration#36

Open
seansfkelley wants to merge 6 commits into
JacobHearst:mainfrom
seansfkelley:main
Open

Add missing fields; add missing standard conformances; improve HTTP error reporting and configuration#36
seansfkelley wants to merge 6 commits into
JacobHearst:mainfrom
seansfkelley:main

Conversation

@seansfkelley
Copy link
Copy Markdown
Contributor

This PR is a grab bag of small changes I made over the course of developing my own project. It includes:

  • adding missing fields: EUR foil/etched prices and Card.flavorName
  • adding missing conformances: Identifiable and Codable on a couple structs that should probably have it like many others do
  • configurable User-Agent header: Scryfall's API docs require that you identify yourself with a unique name and don't use library defaults
  • refined HTTP error handling (breaking change due to new enum members)
    • response-decoding failures are reported explicitly rather than allowing them to throw whatever random decoding error
    • error responses that do not parse from JSON as a well-formed ScryfallError are reported as generic HTTP errors -- this can happen when Scryfall's reverse proxy dumps a default 503 HTML page on you

Sorry it's a bit jumbled. I can split it if up if you'd prefer.

To be honest, the error handling improvements have in practice been pretty marginal, especially the decoding one. The HTTP error one was added after a spurt of 503/504s I got from Scryfall, which allowed me to tell users that Scryfall was down rather than the dreaded "unknown error" (combined with the error object's misleading explanation about decoding failures, which was not the root cause).

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

Successfully merging this pull request may close these issues.

1 participant