protected static function ContentHubClientMock::generateErrorResponse in Acquia Content Hub 8.2
Generates an error response.
Parameters
string $message: The error message.
int $status: The status code of the exception.
1 call to ContentHubClientMock::generateErrorResponse()
- ContentHubClientMock::register in tests/
modules/ acquia_contenthub_server_test/ src/ Client/ ContentHubClientMock.php
File
- tests/
modules/ acquia_contenthub_server_test/ src/ Client/ ContentHubClientMock.php, line 290
Class
- ContentHubClientMock
- Mocks server responses.
Namespace
Drupal\acquia_contenthub_server_test\ClientCode
protected static function generateErrorResponse(string $message, int $status = 0) : void {
$resp_body['error'] = [
'message' => $message,
];
if ($status !== 0) {
$resp_body['error']['code'] = $status;
}
throw new RequestException($message, new Request('POST', \Drupal::request()
->getRequestUri()), new Response($status, [], json_encode($resp_body)));
}