$name($request); } catch (ControllerException $error) { return new WP_REST_Response([ 'errors' => $error->getErrors() ], $error->getCode()); } catch (Throwable $error) { Log::error($error->getMessage(), [ 'error' => $error, 'trace' => $error->getTrace(), ]); $error = [ 'message' => 'Something went wrong', ]; if (current_user_can('manage_options')) { $error['links'] = [ [ 'label' => 'Check the logs', 'url' => aimuse()->menu('#/settings/logs') ] ]; } return new WP_REST_Response([ 'errors' => [ $error ], ], 500); } } } protected function checkPremium() { if (!PremiumHelper::isPremium()) { throw new ControllerException([ [ 'message' => 'You need to upgrade to premium to use this feature' ] ], 400); } } }