Catching “Admin Error” on Client Side and Sending Screenshot / Dump to Server

0
Hello Mendix Community,We are facing a scenario where end users occasionally receive a generic “An error has occurred. Please contact your system administrator.” pop-up (Admin Error).Our application is a web app running behind WAF and DNS routing. The main challenge is that when a WAF blocks a request, Mendix only shows the generic Admin Error pop-up, and there is no server-side trace.In our specific case, the issue may occur before the request even reaches our Mendix runtime (e.g., blocked by a WAF or at the network layer). In the browser DevTools, we can see failed requests (e.g., 403 Forbidden), but the Mendix server does not log the expected API call.We would like to implement a client-side error-capturing mechanism with:Detect when an Admin Error pop-up is shown.Capture technical information such as:Failed request details (status code, URL, response)Console errorPossibly a screenshot of the pageSend this information to the Mendix backend (persist in DB for diagnostics).Is there a supported way to hook into the Mendix client's error-handling mechanism?Has anyone implemented automatic screenshot capture (e.g., using html2canvas) and sent it via a nanoflow/microflow?Thank you!
asked
3 answers
1

In general, you can implement a custom error-handling mechanism to capture and persist technical details at the point where an error occurs. For example, by wrapping critical logic in microflows with proper error handling, you can log the execution step, timestamp, user context, and error message into a dedicated database table for diagnostics.


However, there is no supported way in Mendix to globally intercept or hook into all generic “An error has occurred” (Admin Error) pop-ups. For security and platform integrity reasons, Mendix does not expose a mechanism to centrally capture every client-side runtime error triggered by the framework itself.


As an alternative, it is recommended to implement an in-application “Report an Issue” mechanism. This allows users to submit contextual information about what they were attempting to do, at what stage the issue occurred, and optionally include additional details (e.g., screenshots or descriptions). This approach provides structured diagnostics without relying on unsupported client-side interception.


If this resolves the issue, please close the topic.


answered
1

Hi Joseph Horvath


Your requirement is to intercept Mendix client‑side errors, detect when the Admin Error pop‑up appears, capture diagnostics (failed request, console logs, screenshot), and send them to Mendix for analysis.

There is no officially supported Mendix API that exposes internal client error events or lets you override the Admin Error dialog. The Mendix client does not currently provide hooks into its built‑in error renderer.

So the solution requires an architected extension layer, not a Mendix‑native feature.


You can use HTMLCanava to capture the screen by using JS if you want I can explain it more a bit.

answered
1

Mendix does not expose a supported hook to intercept the standard Admin Error popup directly from the client runtime.

Because in your case the error happens before the request reaches Mendix Runtime (WAF / proxy block), Mendix logging and error handlers are never triggered.

So the correct approach is client-side global error monitoring, not Mendix error popup interception.

Production Solution

1.Capture Client Errors via Global Browser Handlers

Add a small custom JavaScript action / widget and register:



window.onerror = function (message, source, lineno, colno, error) {
    sendErrorToMendix({
        message,
        source,
        lineno,
        colno
    });
};

window.addEventListener("unhandledrejection", function (event) {
    sendErrorToMendix({
        message: event.reason
    });
});

This captures:

  • ✔ Failed requests
  • ✔ JS runtime errors
  • ✔ Network/WAF failures
  • ✔ Admin error situations

2.Capture Failed Network Calls (Important Part)

Override fetch / XHR:



const oldFetch = window.fetch;
window.fetch = async (...args) => {
    const response = await oldFetch(...args);

    if (!response.ok) {
        sendErrorToMendix({
            status: response.status,
            url: args[0]
        });
    }

    return response;
};

This detects 403 / WAF blocked requests even when Mendix never receives them.

3.Screenshot Capture (Supported Workaround)

Use:



html2canvas

inside JS action:



html2canvas(document.body).then(canvas => {
   const image = canvas.toDataURL();
   sendToNanoflow(image);
});

Send Base64 → Nanoflow → Microflow → Store in DB/FileDocument.

4.Send Data Back to Mendix

JS Action → Nanoflow → Microflow

Store:

  • URL
  • Status code
  • Console error
  • User
  • Timestamp
  • Screenshot

Important Mendix Architecture Note

Admin Error popup itself:

  • is generated by Mendix client runtime
  • cannot be extended or overridden officially
  • has no public API hook

So interception must happen before popup rendering using browser listeners.

Most production Mendix apps use:

  • Sentry
  • Datadog RUM
  • Azure App Insights

instead of building custom capture logic.

These automatically capture:

  • network failures
  • screenshots
  • session replay
  • client crashes

There is no supported Mendix hook for Admin Error popup, but the correct solution is:

  • Global JS error listener
  • Network request interception
  • Optional html2canvas screenshot
  • Send diagnostics via Nanoflow/Microflow

This works even when WAF blocks requests before Mendix runtime.

answered