diff --git a/src/Dump.php b/src/Dump.php index c26bc9e..752239b 100644 --- a/src/Dump.php +++ b/src/Dump.php @@ -1,9 +1,7 @@ config = $config; $this->callback = $callback; - $this->transport = $transport ?: new Transport\Curl(); + $this->transport = $transport ?? new Transport\Curl(); $this->exceptionHandler = new Util\ExceptionHandler($dataManipulator); $this->registerHandlers(); } @@ -41,6 +41,7 @@ abstract class Handler { $this->registerErrorHandler && set_error_handler(function(int $severity, string $message, string $file, int $line) { if ( error_reporting() & $severity ) { + $this->pushData(new \ErrorException($message, 0, $severity, $file, $line)); } }); @@ -55,7 +56,7 @@ abstract class Handler { } public function pushData(\Throwable $ex) : ? object - { + { // Make sure not to spam the server if an ErrorMessage or Exception was already sent (like inside a loop) $exceptionHash = $this->exceptionHandler->hash($ex); diff --git a/src/NegundoMiddleware.php b/src/NegundoMiddleware.php index a467e95..d56a3b7 100644 --- a/src/NegundoMiddleware.php +++ b/src/NegundoMiddleware.php @@ -38,6 +38,9 @@ class NegundoMiddleware extends Handler implements MiddlewareInterface { public function handleException(\Throwable $ex) : array { - return $this->exceptionHandler->extractExceptionData($ex, $this->request->getServerParams(), $this->request->getParsedBody()); + $server = isset($this->request) ? $this->request->getServerParams() : $_SERVER; + $body = isset($this->request) ? $this->request->getParsedBody() : $_POST; + + return $this->exceptionHandler->extractExceptionData($ex, $server, $body); } } \ No newline at end of file diff --git a/src/Transport/Curl.php b/src/Transport/Curl.php index e09f592..934d58e 100644 --- a/src/Transport/Curl.php +++ b/src/Transport/Curl.php @@ -20,6 +20,7 @@ class Curl implements TransportInterface { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&')); curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->timeout * 200); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if ( ( false === curl_exec($ch) ) && $this->throwErrors ) { $errno = curl_errno($ch); diff --git a/src/Util/ExceptionHandler.php b/src/Util/ExceptionHandler.php index eceae2d..bc3c104 100644 --- a/src/Util/ExceptionHandler.php +++ b/src/Util/ExceptionHandler.php @@ -27,6 +27,7 @@ class ExceptionHandler { 'code' => $ex->getCode(), 'file' => $ex->getFile(), 'line' => $ex->getLine(), + 'type' => $ex::class, 'message' => $ex->getMessage(), 'url' => ( ( 'on' === $serverData['HTTPS'] ) ? 'https' : 'http' ) . '://' . $serverData['HTTP_HOST'] . $serverData["REQUEST_URI"], 'backtrace' => json_encode($ex->getTrace()),