core-api: fixed confusion around wrong error thrown from routable extensions
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/core-api': patch
|
||||
'@backstage/core': patch
|
||||
---
|
||||
|
||||
Fixed a potentially confusing error being thrown about misuse of routable extensions where the error was actually something different.
|
||||
@@ -47,12 +47,15 @@ export function createRoutableExtension<
|
||||
// Validate that the routing is wired up correctly in the App.tsx
|
||||
try {
|
||||
useRouteRef(mountPoint);
|
||||
} catch {
|
||||
throw new Error(
|
||||
`Routable extension component with mount point ${mountPoint} was not discovered in the app element tree. ` +
|
||||
'Routable extension components may not be rendered by other components and must be ' +
|
||||
'directly available as an element within the App provider component.',
|
||||
);
|
||||
} catch (error) {
|
||||
if (error?.message.startsWith('No path for ')) {
|
||||
throw new Error(
|
||||
`Routable extension component with mount point ${mountPoint} was not discovered in the app element tree. ` +
|
||||
'Routable extension components may not be rendered by other components and must be ' +
|
||||
'directly available as an element within the App provider component.',
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
return <InnerComponent {...props} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user