Pyjo.AWS.Error - Error of an API of AWS¶
from Pyjo.AWS.Client import Client
from Pyjo.AWS.Error import Error
from Pyjo.AWS.Protocol.Query import Query
try:
Client(service='iam', endpoint='https://iam.amazonaws.com', region='us-east-1').call(
Query('GetRole', {'RoleName': 'missing'}, version='2010-05-08')
)
except Error as e:
print(e.code, e.status, e.request_id)
Pyjo.AWS.Error is the error that an API of AWS responds with, which a
call of Pyjo.AWS.Client raises, or rejects its promise with, as
Pyjo.AWS.Protocol reads it of the response: the code of the error,
as AccessDenied or ResourceNotFoundException, its message, the status
of the response and the ID of the request, which the support of AWS asks
for.
See also¶
Classes¶
- exception Pyjo.AWS.Error.Pyjo_AWS_Error(code: str, message: str = '', *, status: int | None = None, request_id: str | None = None, tx: Pyjo_Transaction_HTTP | None = None)[source]¶
Pyjo.AWS.Errorinherits all attributes and methods fromPyjo.Exceptionand implements the following new ones.- __init__(code: str, message: str = '', *, status: int | None = None, request_id: str | None = None, tx: Pyjo_Transaction_HTTP | None = None) None[source]¶
e = Pyjo.AWS.Error.new('AccessDenied', 'Not authorized', status=403, request_id='c6104cbe-...')
Construct a new
Pyjo.AWS.Errorobject, whosemessageis the code and the message of AWS, asAccessDenied: Not authorized.
- code¶
code = e.code
The code of the error, as
AccessDenied, or the status of a response without one, as404.
- request_id¶
request_id = e.request_id
The ID of the request, of the response, or
None.
- status¶
status = e.status
The status of the response, as
403.
- tx¶
tx = e.tx
The transaction of the request and its response, or
None.