Added json_escape function for safe JSON embedding and updated error handling to include user abort messages.