Skip to content

Commit f60da36

Browse files
Enhance errors when adding and removing sources
1 parent 6864c59 commit f60da36

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/ipc/error.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright (c) 2022 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5+
*/
6+
7+
export const cleanIpcErrorMessage = (message, replacecment = '') =>
8+
message.replace(
9+
/Error invoking remote method '.*?': *(Error:)? */,
10+
replacecment
11+
);

src/launcher/actions/settingsActions.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { ErrorDialogActions } from 'pc-nrfconnect-shared';
1010

11+
import { cleanIpcErrorMessage } from '../../ipc/error';
1112
import {
1213
invokeGetFromRenderer as getSetting,
1314
sendSetFromRenderer as setSetting,
@@ -121,7 +122,14 @@ export function addSource(url) {
121122
addSourceInMain(url)
122123
.then(source => dispatch(addSourceAction(source, url)))
123124
.catch(error =>
124-
dispatch(ErrorDialogActions.showDialog(error.message))
125+
dispatch(
126+
ErrorDialogActions.showDialog(
127+
cleanIpcErrorMessage(
128+
error.message,
129+
'Error while trying to add a source: '
130+
)
131+
)
132+
)
125133
)
126134
.then(() => dispatch(AppsActions.loadOfficialApps()));
127135
};
@@ -141,6 +149,16 @@ export function removeSource(name) {
141149
.then(() => dispatch(AppsActions.loadOfficialApps()))
142150
.then(async () =>
143151
dispatch(await AppsActions.setAppManagementSource(name))
152+
)
153+
.catch(error =>
154+
dispatch(
155+
ErrorDialogActions.showDialog(
156+
cleanIpcErrorMessage(
157+
error.message,
158+
`Error while trying to remove the source '${name}': `
159+
)
160+
)
161+
)
144162
);
145163
};
146164
}

0 commit comments

Comments
 (0)