Skip to content

Handle errors from the API #17

@technicalpickles

Description

@technicalpickles

I hadn't tried running this in awhile, and got:

/Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/buildkite-cli-0.1.0/lib/bk/commands/artifacts.rb:93:in `call': undefined method `build' for nil (NoMethodError)

          build = result.data.build
                             ^^^^^^
	from /Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/dry-cli-1.0.0/lib/dry/cli.rb:116:in `perform_registry'
	from /Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/dry-cli-1.0.0/lib/dry/cli.rb:65:in `call'
	from /Users/josh.nichols/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/buildkite-cli-0.1.0/exe/bk:5:in `<top (required)>'
	from /Users/josh.nichols/.rbenv/versions/3.3.1/bin/bk:25:in `load'
	from /Users/josh.nichols/.rbenv/versions/3.3.1/bin/bk:25:in `<main>'

Code is:

result = query(BuildArtifactsQuery, variables: {slug: slug, jobs_after: jobs_after})

def query(graphql_query, **kwargs)
result = nil
spinner.run("Done") do |spinner|
result = Client.query(graphql_query, **kwargs)
end
result
end

I suspect there's a class of non-200 we should just handle, and surface to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions