"; var_dump($v); echo ""; } die(); } } if (!function_exists('safe_error')) { /** * Log exception details securely and return a safe user-facing message. * Full details go to error_log; users only see a generic Arabic message. * * @param \Throwable $e The caught exception * @param string $context Short label for the endpoint (e.g. 'invoices/upload') * @param string $userMsg Arabic message shown to the user * @param int $code HTTP status code */ function safe_error(\Throwable $e, string $context, string $userMsg = 'حدث خطأ غير متوقع. يرجى المحاولة مرة أخرى.', int $code = 500): void { error_log("[{$context}] " . get_class($e) . ': ' . $e->getMessage() . ' | ' . $e->getFile() . ':' . $e->getLine()); json_error($userMsg, $code); } }