Skip to content

When GitHub reports an error, the API just throws a TypeError instead of throwing a useful exception #411

Open
@Hixie

Description

@Hixie

For example, I tried calling addLabelsToIssue on an issue that, as it turns out, had been deleted. Instead of a useful exception telling me the response from GitHub, I got type '_Map<String, dynamic>' is not a subtype of type 'List<dynamic>' (_TypeError) at GitHub.requestJson (package:github/src/common/github.dart:335:35), which it turns out is not at all useful. (I had to add prints in the GitHub package to figure out what the problem was.)

For what it's worth, the response from GitHub looked like this:

{"message":"Validation Failed","errors":[{"resource":"Label","code":"unprocessable","field":"data","message":"Could not resolve to a node with the global id of 'I_kwDOAeUeuM6artTz'."}],"documentation_url":"https://docs.github.com/rest/issues/labels#add-labels-to-an-issue","status":"422"}

It seems like it's probably the case that we could add some general code to catch errors for all API calls and throw some general exceptions that encode the kinds of information GitHub returns. (Maybe HTTP status codes other than 200 should always throw, or something.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy