Skip to content

Commit bcb78bc

Browse files
authored
fix(bulk-import): fix import api error message for generic error (#766)
1 parent 10579ce commit bcb78bc

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-bulk-import': patch
3+
---
4+
5+
fix generic error when pr creation fails

workspaces/bulk-import/plugins/bulk-import/src/components/AddRepositories/AddRepositories.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import Alert from '@mui/material/Alert';
1919
import AlertTitle from '@mui/material/AlertTitle';
2020
import FormControl from '@mui/material/FormControl';
2121
import { useFormikContext } from 'formik';
22-
import { get } from 'lodash';
2322

2423
import { AddRepositoriesFormValues, PullRequestPreviewData } from '../../types';
2524
import { PreviewFileSidebar } from '../PreviewFile/PreviewFileSidebar';
@@ -45,6 +44,9 @@ export const AddRepositories = ({ error }: { error: any }) => {
4544
});
4645
setOpenDrawer(false);
4746
};
47+
48+
const errorMessage = error?.error?.message && JSON.parse(error.error.message);
49+
4850
return (
4951
<>
5052
<FormControl fullWidth>
@@ -57,8 +59,14 @@ export const AddRepositories = ({ error }: { error: any }) => {
5759
{error && (
5860
<div style={{ paddingBottom: '10px' }}>
5961
<Alert severity="error">
60-
<AlertTitle>{get(error, 'name') || 'Error occured'}</AlertTitle>
61-
{get(error, 'err') || 'Failed to create pull request'}
62+
<AlertTitle>
63+
{errorMessage?.error?.name ??
64+
error?.error?.name ??
65+
'Error occured'}
66+
</AlertTitle>
67+
{errorMessage?.error?.message ??
68+
error?.err ??
69+
'Failed to create pull request'}
6270
</Alert>
6371
</div>
6472
)}

0 commit comments

Comments
 (0)