Skip to content

typeError - cannot read property 'line' of undefined #9

@li-boxuan

Description

@li-boxuan

I am using graphql-client to fetch data from GitHub.

Usually, errors returned from GitHub looks like this:

[{"message":"Could not resolve to an Organization with the login of 'GCI-AOSSIE'.","type":"NOT_FOUND","path":["organization"],"locations":[{"line":2,"column":3}]}]

However, sometimes GitHub returns errors as follows:

[{"message":"Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include `E689:1AF6:67E816:BAAF4C:5BD321E1` when reporting this issue."}]

Note that it doesn't have locations field.
Under the latter circumstance,

var locations = errors.map(function (e) { return e.locations })

together with
var lineErrors = locations.filter(function (loc) { return loc && loc.line === line })

would cause an error: cannot read property 'line' of undefined

c.f. coala/gci-leaders#161 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions