Address review feedback: simplify toError and add changeset

- Remove JSON.stringify fallback from toError, use the same unknown
  error messaging as stringifyError for all non-string/non-error values
- Add try/catch to protect against values that throw on string
  conversion (e.g. null-prototype objects, symbols)
- Fix no-op `void toError(err)` in DeleteEntityConfirmationDialog
- Fix `${err}` producing [object Object] in UrlReaderProcessor
- Fix double toError call in openStackSwift
- Update JSDoc to accurately describe the behavior
- Add tests for throwing toString and circular objects
- Add changeset for all refactored packages

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-04-03 11:02:11 +02:00
parent b2319ffe45
commit 482ceed6d2
8 changed files with 76 additions and 36 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/errors': minor
---
A new `toError` utility function is now available for converting unknown values to `ErrorLike` objects. If the value is already error-like it is returned as-is. Strings are used directly as the error message, and other values are stringified with a fallback to JSON to avoid unhelpful messages like `[object Object]`. Non-error causes passed to `CustomErrorBase` are now converted and stored using `toError` rather than discarded.
A new `toError` utility function is now available for converting unknown values to `ErrorLike` objects. If the value is already error-like it is returned as-is, strings are used directly as the error message, and all other values are wrapped as `unknown error '<stringified>'`. Non-error causes passed to `CustomErrorBase` are now converted and stored using `toError` rather than discarded.
+30
View File
@@ -0,0 +1,30 @@
---
'@backstage/backend-app-api': patch
'@backstage/backend-defaults': patch
'@backstage/cli': patch
'@backstage/cli-common': patch
'@backstage/cli-module-migrate': patch
'@backstage/cli-module-new': patch
'@backstage/cli-node': patch
'@backstage/config-loader': patch
'@backstage/core-components': patch
'@backstage/repo-tools': patch
'@backstage/plugin-auth': patch
'@backstage/plugin-auth-backend': patch
'@backstage/plugin-catalog': patch
'@backstage/plugin-catalog-backend': patch
'@backstage/plugin-catalog-backend-module-incremental-ingestion': patch
'@backstage/plugin-catalog-import': patch
'@backstage/plugin-catalog-react': patch
'@backstage/plugin-catalog-unprocessed-entities': patch
'@backstage/plugin-devtools-backend': patch
'@backstage/plugin-mcp-actions-backend': patch
'@backstage/plugin-notifications-backend-module-slack': patch
'@backstage/plugin-scaffolder-backend': patch
'@backstage/plugin-scaffolder-backend-module-github': patch
'@backstage/plugin-search-backend-node': patch
'@backstage/plugin-techdocs-backend': patch
'@backstage/plugin-techdocs-node': patch
---
Migrated from `assertError` to `toError` for error handling.