Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/next-release/enhancement-Endpoints-18366.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "enhancement",
"category": "Endpoints",
"description": "Improve the NoRegionError message to explain how to set a region (region_name, AWS_DEFAULT_REGION, or ~/.aws/config)."
}
7 changes: 6 additions & 1 deletion botocore/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ class BaseEndpointResolverError(BotoCoreError):
class NoRegionError(BaseEndpointResolverError):
"""No region was specified."""

fmt = 'You must specify a region.'
fmt = (
'You must specify a region. Set it via the region_name argument '
'to the client/Session, the AWS_DEFAULT_REGION environment '
'variable, or "region" in ~/.aws/config (note: region goes in '
'~/.aws/config, not ~/.aws/credentials).'
Comment thread
viveka76 marked this conversation as resolved.
Outdated
)


class EndpointVariantError(BaseEndpointResolverError):
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ def test_ensures_region_is_not_none(self):
with self.assertRaises(NoRegionError):
resolver = regions.EndpointResolver(self._template())
resolver.construct_endpoint('foo', None)
message = str(ctx.exception)
self.assertIn('You must specify a region', message)
self.assertIn('AWS_DEFAULT_REGION', message)
Comment thread
viveka76 marked this conversation as resolved.
Outdated

def test_ensures_required_keys_present(self):
with self.assertRaises(ValueError):
Expand Down