Notifications & Logging
UI Popups
Pragma CMS uses a centralized popup system to provide feedback to the user without interrupting their workflow.
displaySuccessPopup()
Displays a temporary green toast notification at the bottom of the screen. Old popups are automatically cleared to prevent stacking.
Signature:
function displaySuccessPopup(message, targetElement = null)
displayErrorPopup()
Displays a detailed error modal.
Feature: If the error message contains HTML <pre> tags (often generated by server-side exceptions), the popup automatically appends a "Copy" button to allow developers to easily copy the stack trace.
Signature:
function displayErrorPopup(message, autoCloseDuration = 0)
Example:
displayErrorPopup("Invalid Database Connection.", 5000); // Closes automatically after 5s
The Global Logger (pushLogEntry)
The Admin Panel includes a hidden "Log Panel" (accessible via the alert icon in the top right). Developers can push messages to this panel for silent debugging.
Signature:
function pushLogEntry(message, level)
// Levels: "success", "error", "warning", "info"
Automatic Error Capture (IIFE)
Pragma CMS automatically captures unhandled JavaScript errors and pushes them to the Log Panel. You do not need to configure this; it runs globally:
window.onerror: Captures native syntax and runtime errors, logging the exact file and line number.unhandledrejection: Captures failed Async/Await Promises.console.errorHook: Interceptsconsole.error(), logs the message to the panel, and automatically runsconsole.trace()in the DevTools to provide a complete stack trace of who called the error.