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.

ClientError feels very general

See original GitHub issue

I’ve just started using boto3 (after years with the previous version) so I’ve been getting to grips with the new api today.

One thing that stuck out at me is how one needs to catch and inspect ClientError to determine existence when working at the resource level (eg https://boto3.readthedocs.org/en/latest/guide/migrations3.html#accessing-a-bucket).

Maybe I’m missing something but it feels like those various exceptions should be wrapped as more specific exceptions so they could at least be caught directly. Something along the lines of:

try:
    s3.meta.client.head_bucket(Bucket='mybucket')
except BucketNotFoundError as e:
    pass

As it stands it seems I need to do a bunch of 404 checks for testing if s3 keys exist etc. Maybe there’s a better way of doing it?

It does feel a little like the level of abstraction is a bit close to the underlying aws implementation - but maybe that’s the intention?

As ever, thanks for an amazing and solid bit of software.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:29
  • Comments:23 (5 by maintainers)

github_iconTop GitHub Comments

12reactions
markddavidoffcommented, Apr 17, 2018

If anyone else ends up here looking for a list of error codes, the ClientError.response['Error']['Code'] error codes come from the aws sdk and can be found here

5reactions
kislyukcommented, Oct 14, 2015

+1. I would prefer if an error class were vivified from ClientError.response[“error”][“code”], so instead of writing:

try:
    ...
except botocore.exceptions.ClientError as e:
    if e.response.get("Error", {}).get("Code") == "...":
        ...
    else:
        raise

or something else equally brittle and yucky, I could just write except botocore.exceptions.LimitExceeded, etc. If they all inherit from ClientError, this is a fully backward compatible change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling — Boto3 Docs 1.26.32 documentation - AWS
The most common botocore exception you'll encounter is ClientError . This is a general exception when an error response is provided by an...
Read more >
How to handle errors with boto3? - Stack Overflow
Use the response contained within the exception. Here is an example: import boto3 from botocore.exceptions import ClientError try: iam = boto3.client('iam') ...
Read more >
Tns - 12560 - Client error — oracle-tech
Hi everyone, i'm facing a problem very strange. I have my base in a Enterprise Linux. And in there, everything works fine, listener...
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
Client error responses. 400 Bad Request. The server cannot or will not process the request due to something that is perceived to be...
Read more >
Status Codes - Neo4j
This is a read only database, writing or modifying the database is not allowed. Neo.ClientError.General.InvalidArguments. The request contained fields that were ...
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