improved errorhandler, send non fatal errors async
This commit is contained in:
parent
85d9f28166
commit
e393bf0b4f
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace ManiaControl;
|
namespace ManiaControl;
|
||||||
|
|
||||||
|
use ManiaControl\Files\AsyncHttpRequest;
|
||||||
use ManiaControl\Plugins\PluginManager;
|
use ManiaControl\Plugins\PluginManager;
|
||||||
use ManiaControl\Update\UpdateManager;
|
use ManiaControl\Update\UpdateManager;
|
||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
@ -161,6 +162,8 @@ class ErrorHandler {
|
|||||||
$info = base64_encode($json);
|
$info = base64_encode($json);
|
||||||
|
|
||||||
$url = ManiaControl::URL_WEBSERVICE . 'errorreport?error=' . urlencode($info);
|
$url = ManiaControl::URL_WEBSERVICE . 'errorreport?error=' . urlencode($info);
|
||||||
|
|
||||||
|
if ($isFatalError) {
|
||||||
$response = WebReader::getUrl($url);
|
$response = WebReader::getUrl($url);
|
||||||
$content = $response->getContent();
|
$content = $response->getContent();
|
||||||
$success = json_decode($content);
|
$success = json_decode($content);
|
||||||
@ -169,6 +172,25 @@ class ErrorHandler {
|
|||||||
} else {
|
} else {
|
||||||
Logger::log('Error-Report failed! ' . print_r($content, true));
|
Logger::log('Error-Report failed! ' . print_r($content, true));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//Async Report
|
||||||
|
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, $url);
|
||||||
|
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
|
||||||
|
$asyncHttpRequest->setCallable(function ($json, $error) {
|
||||||
|
if ($error) {
|
||||||
|
Logger::logError("Error while Sending Error Report");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$success = json_decode($json);
|
||||||
|
if ($success) {
|
||||||
|
Logger::log('Error-Report successful!');
|
||||||
|
} else {
|
||||||
|
Logger::log('Error-Report failed! ' . print_r($json, true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$asyncHttpRequest->getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isFatalError) {
|
if ($isFatalError) {
|
||||||
|
Loading…
Reference in New Issue
Block a user