-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- module_utils.botocore - refactorization of ``get_aws_region``, ``get_aws_connection_info`` and ``get_aws_connection_info`` so that the code can be reused by non-module plugins (https://github.com/ansible-collections/amazon.aws/pull/1231). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# (c) 2022 Red Hat Inc. | ||
# | ||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
from ansible.module_utils._text import to_native | ||
|
||
|
||
class AnsibleAWSError(Exception): | ||
|
||
def __str__(self): | ||
if self.exception and self.message: | ||
return "{0}: {1}".format(self.message, to_native(self.exception)) | ||
|
||
return super(AnsibleAWSError, self).__str__() | ||
|
||
def __init__(self, message=None, exception=None, **kwargs): | ||
if not message and not exception: | ||
super(AnsibleAWSError, self).__init__() | ||
if not message: | ||
super(AnsibleAWSError, self).__init__(exception) | ||
if not exception: | ||
super(AnsibleAWSError, self).__init__(message) | ||
|
||
self.exception = exception | ||
self.message = message | ||
|
||
# In places where passing more information to module.fail_json would be helpful | ||
# store the extra info. Other plugin types have to raise the correct exception | ||
# such as AnsibleLookupError, so can't easily consume this. | ||
self.kwargs = kwargs or {} | ||
|
||
|
||
class AnsibleBotocoreError(AnsibleAWSError): | ||
pass |