NamespaceExceptionFactory
in package
implements
ExceptionFactoryInterface
Attempts to create exceptions by inferring the name from the code and a base namespace that contains exceptions. Exception classes are expected to be in upper camelCase and always end in 'Exception'. 'Exception' will be appended if it is not present in the exception code.
Table of Contents
Interfaces
- ExceptionFactoryInterface
- Interface used to create AWS exception
Properties
- $baseNamespace : string
- $defaultException : string
- $parser : ExceptionParserInterface
Methods
- __construct() : mixed
- fromResponse() : Exception|AwsExceptionInterface
- Returns an AWS service specific exception
- createException() : Exception
- Create an prepare an exception object
Properties
$baseNamespace
protected
string
$baseNamespace
Base namespace containing exception classes
$defaultException
protected
string
$defaultException
Default class to instantiate if a match is not found
$parser
protected
ExceptionParserInterface
$parser
Parser used to parse responses
Methods
__construct()
public
__construct(ExceptionParserInterface $parser, string $baseNamespace[, string $defaultException = 'AwsCommonExceptionServiceResponseException' ]) : mixed
Parameters
- $parser : ExceptionParserInterface
-
Parser used to parse exceptions
- $baseNamespace : string
-
Namespace containing exceptions
- $defaultException : string = 'AwsCommonExceptionServiceResponseException'
-
Default class to use if one is not mapped
fromResponse()
Returns an AWS service specific exception
public
fromResponse(RequestInterface $request, Response $response) : Exception|AwsExceptionInterface
Parameters
- $request : RequestInterface
-
Unsuccessful request
- $response : Response
-
Unsuccessful response that was encountered
Return values
Exception|AwsExceptionInterfacecreateException()
Create an prepare an exception object
protected
createException(string $className, RequestInterface $request, Response $response, array<string|int, mixed> $parts) : Exception
Parameters
- $className : string
-
Name of the class to create
- $request : RequestInterface
-
Request
- $response : Response
-
Response received
- $parts : array<string|int, mixed>
-
Parsed exception data