diff --git a/.changeset/shy-owls-grab.md b/.changeset/shy-owls-grab.md
new file mode 100644
index 0000000000..ccee56c153
--- /dev/null
+++ b/.changeset/shy-owls-grab.md
@@ -0,0 +1,5 @@
+---
+'@backstage/core': patch
+---
+
+Reuse ResponseErrorList for non ResponseErrors
diff --git a/packages/core/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx b/packages/core/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx
index c36be78f08..52f7ab03f9 100644
--- a/packages/core/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx
+++ b/packages/core/src/components/ResponseErrorPanel/ResponseErrorPanel.tsx
@@ -39,6 +39,78 @@ const useStyles = makeStyles(theme => ({
},
}));
+type ResponseErrorListProps = {
+ error: string;
+ message: string;
+ request?: string;
+ stack?: string;
+ json?: string;
+};
+
+const ResponseErrorList = ({
+ error,
+ request,
+ message,
+ stack,
+ json,
+}: ResponseErrorListProps) => {
+ const classes = useStyles();
+
+ return (
+
+
+
+
+
+
+
+
+
+ {request && (
+
+
+
+
+ )}
+ {stack && (
+
+
+
+
+ )}
+ {json && (
+ <>
+
+
+ }
+ />
+
+
+ >
+ )}
+
+ );
+};
+
type Props = {
error: Error;
};
@@ -50,13 +122,13 @@ type Props = {
* server-provided information about what happened.
*/
export const ResponseErrorDetails = ({ error }: Props) => {
- const classes = useStyles();
-
if (error.name !== 'ResponseError') {
return (
-
-
-
+
);
}
@@ -70,53 +142,13 @@ export const ResponseErrorDetails = ({ error }: Props) => {
const jsonString = JSON.stringify(data, undefined, 2);
return (
-
-
-
-
-
-
-
-
-
- {requestString && (
-
-
-
-
- )}
- {stackString && (
-
-
-
-
- )}
-
-
- }
- />
-
-
-
+
);
};