Skip to content

feat: Display unhandled exceptions from the Controller extension inside the Info Center.#4627

Merged
avasilev-sap merged 5 commits into
mainfrom
feat/4626/controller-extension-errors
May 12, 2026
Merged

feat: Display unhandled exceptions from the Controller extension inside the Info Center.#4627
avasilev-sap merged 5 commits into
mainfrom
feat/4626/controller-extension-errors

Conversation

@avasilev-sap
Copy link
Copy Markdown
Contributor

@avasilev-sap avasilev-sap commented Apr 30, 2026

#4626

Register handlers on the globalThis object for error or promise rejection events. Any error containing in its stack trace the pattern /changes/coding/path/to/ts/or/js file will be displayed. This is a reliable check because all controllers reside in the changes/coding folder inside the adp project.

Screenshot 2026-04-30 at 14 22 20 Screenshot 2026-04-30 at 14 22 31 Screenshot 2026-04-30 at 14 23 19 Screenshot 2026-04-30 at 14 23 32 Screenshot 2026-04-30 at 14 39 51 Screenshot 2026-04-30 at 14 40 06

Testing done:

  • Create a controller and a fragment containing a button. The controller throws an exception when the button is clicked. The error is displayed in the Info center.
  • When a controller onInit hook throws runtime error or a promise which is rejected the corresponding error is displayed in the info center.
sap.ui.define(
  [
    "sap/ui/core/mvc/ControllerExtension"
  ],
  function (
    ControllerExtension
  ) {
    "use strict";
    return ControllerExtension.extend("adp.v2app.share", {
      onBtnPress: function () {
        throw new Error("Error on press share button");
      },
      override: {
        onInit: function () {
          // throw new Error('Controller initialization error')
          new Promise((_, reject) => {
            setTimeout(() => {
              reject(new Error("Async controller initialization error"));
            }, 1000);
          });
        }
      },
    });
  },
);

…n inside the Info Center.

Register handlers on the globalThis object for error or promise rejection events. Any error containing in its stack trace the pattern /changes/coding/path/to/ts/or/js file will be displayed. This is a reliable check because all controllers reside in the changes/coding folder inside the adp project.
@avasilev-sap avasilev-sap self-assigned this Apr 30, 2026
@avasilev-sap avasilev-sap added preview-middleware @sap-ux/preview-middleware control-property-editor @sap-ux/control-property-editor labels Apr 30, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: c1f926e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@sap-ux-private/preview-middleware-client Patch
@sap-ux/preview-middleware Patch
@sap-ux/create Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@avasilev-sap avasilev-sap marked this pull request as ready for review April 30, 2026 15:03
@avasilev-sap avasilev-sap requested review from a team as code owners April 30, 2026 15:03
@hyperspace-insights
Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Display Unhandled Controller Extension Errors in the Info Center

New Feature

✨ Adds global error detection for unhandled exceptions and promise rejections originating from Controller Extensions in the Adaptation Project editor. Matching errors are surfaced as error-level messages in the Info Center panel, helping developers quickly identify runtime issues in their controller code.

Errors are identified by checking if the stack trace contains the pattern /changes/coding/<filename>.(js|ts), which reliably targets controller extension files stored in the ADP project's changes/coding folder.

Changes

  • packages/preview-middleware-client/src/flp/init.ts: Added CONTROLLER_EXTENSION_PATH_REGEX pattern, extractError helper to retrieve an Error from both ErrorEvent and PromiseRejectionEvent, reportControllerExtensionErrorToInfoCenter handler that filters by stack trace and sends a message to the Info Center, and registerForControllerExtensionErrors which attaches both error and unhandledrejection listeners to globalThis. The registration is called during FLP init when flex settings are present.
  • packages/preview-middleware-client/src/messagebundle.properties: Added the CONTROLLER_EXTENSION_UNHANDLED_ERROR_TITLE i18n key used as the Info Center message title.
  • packages/preview-middleware-client/test/unit/flp/init.test.ts: Added a registerForControllerExtensionErrors test suite covering: reporting ErrorEvent with a .js stack trace, reporting unhandledrejection with a .ts stack trace, ignoring unrelated errors, ignoring non-Error objects, ignoring undefined errors, and handling errors with an empty message.
  • .changeset/twelve-poets-type.md: Added a patch-level changeset entry for @sap-ux-private/preview-middleware-client.

Images and Links

Info Center error display
Error detail view
Promise rejection example
Rejection detail view
Additional screenshot
Additional detail

GitHub Issue #4626: Display unhandled exceptions from the Controller extension inside the Info Center


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.37

Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR introduces a useful feature but has a few correctness issues to address: the global event listeners are never deregistered (creating a leak and potential duplicate-firing across test runs), non-Error promise rejection reasons are silently dropped even when they originate from a controller extension path, and the test suite's afterEach does not clean up the registered listeners, making repeated test executions unreliable.

PR Bot Information

Version: 1.20.37

  • LLM: anthropic--claude-4.6-sonnet
  • Agent Instructions:
  • File Content Strategy: Full file content
  • Event Trigger: pull_request.ready_for_review
  • Correlation ID: 6cf7330c-f14c-4a21-8564-3dcca3ba6934

Comment thread packages/preview-middleware-client/src/flp/init.ts
Comment thread packages/preview-middleware-client/src/flp/init.ts
Comment thread packages/preview-middleware-client/src/flp/init.ts
Comment thread packages/preview-middleware-client/test/unit/flp/init.test.ts
Copy link
Copy Markdown
Contributor

@lfindlaysap lfindlaysap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avasilev-sap, also in your screenshot "Target was not found" should not end with a period and "controller initialization error" is very generic and not phrased as a sentence. Could you show me where I can suggest changes to them as well?

Comment thread packages/preview-middleware-client/src/messagebundle.properties Outdated
@avasilev-sap
Copy link
Copy Markdown
Contributor Author

avasilev-sap commented May 7, 2026

@avasilev-sap, also in your screenshot "Target was not found" should not end with a period and "controller initialization error" is very generic and not phrased as a sentence. Could you show me where I can suggest changes to them as well?

The "Target was not found" text is from the application itself. It is not localized or set from our codebase. The text is set as a binding,

bindingString: "{_templPrivGlobal>/generic/messagePage/text}"
oValue: "Target was not found."

You can contact sb from the UI5/RTA team if you want to change the translation.

The second text "controller initialization error" is a dummy text which i used to throw as an exception from a dummy controller just to test the feature. In the Testing done section of this PR there is a small Controller which throws the latter exception. This text is not part of the project, please ignore it.

Copy link
Copy Markdown
Contributor

@Jimmy-Joseph19 Jimmy-Joseph19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good.
Covered with unit test
Changeset found
Ran the branch against integration test result - Paased
https://github.com/SAP/open-ux-tools/actions/runs/25503795851
Did not test locally

Copy link
Copy Markdown
Contributor

@IvoSG IvoSG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good.
Good test coverage
Changeset is ok
Did not test locally

@sonarqubecloud
Copy link
Copy Markdown

@avasilev-sap avasilev-sap merged commit be5476f into main May 12, 2026
18 checks passed
@avasilev-sap avasilev-sap deleted the feat/4626/controller-extension-errors branch May 12, 2026 07:51
devinea added a commit that referenced this pull request May 12, 2026
…t_take2

* origin/main:
  Project modules update 12.05.2026 (5242) (#4661)
  update skill name (#4658)
  chore: apply latest changesets
  feat: Display unhandled exceptions from the Controller extension inside the Info Center. (#4627)
  chore: apply latest changesets
  feat: update splitter for new ui (#4648)
  chore: apply latest changesets
  tbi(generator-odata-downloader): Make self contained (#4656)
  chore: apply latest changesets
  fix: change confirm replace additional message based on environment (#4628)
  chore: apply latest changesets
  fix(sap-systems-ext): add new create new command (#4645)
  chore: apply latest changesets
  (fiori-mcp-server) add additional guidance on the adding of extension in fiori (#4643)
  test: update skill (#4651)
  chore: apply latest changesets
  fix: Add fragment list to model for custom fragments (#4601)
  chore: apply latest changesets
  Docs(eslint-plugin-fiori-tools): add cds code snippets to rule documentation (#4623)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

control-property-editor @sap-ux/control-property-editor preview-middleware @sap-ux/preview-middleware

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants