Skip to content

Handle createHook errors #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jimmyshiau opened this issue Dec 11, 2019 · 2 comments · May be fixed by #225
Open

Handle createHook errors #194

jimmyshiau opened this issue Dec 11, 2019 · 2 comments · May be fixed by #225

Comments

@jimmyshiau
Copy link
Contributor

When I have no permission to create hook, github server will return error message

{
  message: Not Found,  
  documentation_url: https://developer.github.com/v3/repos/hooks/#create-a-hook
}

Can you throws NotFound error here?

Future<Hook> createHook(RepositorySlug slug, CreateHook hook) async {
ArgumentError.checkNotNull(slug);
ArgumentError.checkNotNull(hook);
return github.postJSON<Map<String, dynamic>, Hook>(
'/repos/${slug.fullName}/hooks',
convert: (i) => Hook.fromJson(i)..repoName = slug.fullName,
body: jsonEncode(hook),
);
}

@github-actions
Copy link

Thanks for submitting an issue! @robrbecker will take a look soon!

@axel-op
Copy link
Contributor

axel-op commented May 30, 2020

What should be added to the postJSON call is an expected status code of 201 Created, so the API would throw if the returned code was different.

@axel-op axel-op linked a pull request May 31, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants