private function StreamHandler::createResource in Lockr 7.3
Create a resource and check to ensure it was created successfully
Parameters
callable $callback Callable that returns stream resource:
Return value
resource
Throws
\RuntimeException on error
1 call to StreamHandler::createResource()
- StreamHandler::createStream in vendor/
guzzlehttp/ guzzle/ src/ Handler/ StreamHandler.php
File
- vendor/
guzzlehttp/ guzzle/ src/ Handler/ StreamHandler.php, line 230
Class
- StreamHandler
- HTTP handler that uses PHP's HTTP stream wrapper.
Namespace
GuzzleHttp\HandlerCode
private function createResource(callable $callback) {
$errors = null;
set_error_handler(function ($_, $msg, $file, $line) use (&$errors) {
$errors[] = [
'message' => $msg,
'file' => $file,
'line' => $line,
];
return true;
});
$resource = $callback();
restore_error_handler();
if (!$resource) {
$message = 'Error creating resource: ';
foreach ($errors as $err) {
foreach ($err as $key => $value) {
$message .= "[{$key}] {$value}" . PHP_EOL;
}
}
throw new \RuntimeException(trim($message));
}
return $resource;
}