Skip to content
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

Improve handling of errors returned by bitbucket. #32

Open
mikerussellnz opened this issue Feb 6, 2017 · 0 comments
Open

Improve handling of errors returned by bitbucket. #32

mikerussellnz opened this issue Feb 6, 2017 · 0 comments

Comments

@mikerussellnz
Copy link

When creating a pull request via PullRequests.Create if the specified from branch / to branch is not found, bitbucket will return 404 not found. But the contents of the response will be a JSON structure that explains what was not found.

The issue is this JSON response is never read if the HTTP status code is 404.

The exception thrown is:
POST operation unsuccessful. Got HTTP status code 404.

I have modified a local checkout of the code to add reading the response data, which provides me the JSON error details as text in the exception:

Modified code - HttpCommunicationWorker, Line 97:

                string error = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                throw new Exception(string.Format("POST operation unsuccessful. Got HTTP status code '{0}' \nContent:\n{1}", httpResponse.StatusCode, error));

This is not ideal as it would be nice to deserialize the JSON error response to some sort of class structure.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants