question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bitbucket on-prem] Errors processing

See original GitHub issue

Hello,

I just recently started to use this framework and quickly found you myself writing a lot of “safety belts” with try/except. For example, if I want to check whether the Bitbucket repo exist, I would use bitbucket.get_repo(project_key, repo_slug) but it must be wrapped into try/except because if repo doesn’t exist I won’t receive None or something similar; instead, framework will fail with an exception and in order to process it properly I am parsing Exception’s with something like e.response.content.decode("utf8")["errors"] in a try to find out what exactly happened.

I’m wondering what was the driving decision for this approach or maybe I am missing something such as proper errors processing, etc.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Spacetowncommented, Jan 11, 2021

@AjaxOdessa Following code should be enough:

        exists = False
        try:
            bitbucket.get_repo(project_key, repository_slug)
            exists = True
        except HTTPError as e:
            # 404: The specified repository does not exist.
            if e.response.status_code == 404:
                pass
            # 401: The currently authenticated user has insufficient permissions to see the specified repository.. Rethrow???

        return False
0reactions
AjaxOdessacommented, Jan 11, 2021

Yeah, I got it by

401: The currently authenticated user…

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Bitbucket Cloud JIRA Server Connection - API Error
Solved: We're trying to set up connection between Bitbucket Cloud & JIRA (on-prem) server as per the steps outlined -
Read more >
Bitbucket Overview
Cloud Server Data center Git repository hosting Cloud Server Data center Branch permissions Cloud Server Data center Jira Software integration Cloud Server Data center
Read more >
Bitbucket Down? Bitbucket Issues? That's Why You Need ...
#4 Bitbucket down as an effect of software and hardware failures ... Losing access to your Bitbucket data could be also influenced by...
Read more >
Bitbucket Server Integration - Jenkins Plugins
Link directly from Bitbucket to the logs for each build. The plugin streamlines the entire configuration process and removes the need for multiple...
Read more >
Build repositories from Bitbucket Server - Google Cloud
Creating a Bitbucket Server trigger. This sections explains how you can connect your Bitbucket Server repositories to Cloud Build and create a trigger...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found