I'm working on an addon and have a controller which makes a POST request to an external service that I'm also building. I'm attempting to make it so if Xenforo sends a request to that service and that service is offline or otherwise causes Guzzle to throw a RequestException and display the red error window to the browser to not do that, and instead just do nothing if the request fails. The action function looks similar to this:
Even with that try/catch in place, I still am shown the red error window. I've also tried catching RequestException instead of just Exception, and setting the request's 'http_errors' variable to false - neither of which stopped Xenforo from catching the error. Is there any way to override Xenforo's default error handling?
PHP:
public function actionRegister(ParameterBag $params) {
$visitor = \XF::visitor();
$client = \XF::app()->http()->client();
$success = false;
try {
$res = $client->post('http://127.0.0.1:9998', [
'body' => [
'user_id' => $visitor->user_id
]
]);
$success = true;
} catch (Exception $e) {
// Do nothing.
}
$viewParams = [
"success" => $success,
];
return $this->view('AddOn:Index', 'addon_index', $viewParams);
}
Even with that try/catch in place, I still am shown the red error window. I've also tried catching RequestException instead of just Exception, and setting the request's 'http_errors' variable to false - neither of which stopped Xenforo from catching the error. Is there any way to override Xenforo's default error handling?