Skip to content

Commit

Permalink
chore: add error handling when importing map style
Browse files Browse the repository at this point in the history
  • Loading branch information
lightlii committed Jul 27, 2023
1 parent 851ccf7 commit 3bbef99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ module.exports = function (ipcSend) {
return result
})

ipcMain.on('show-error-dialog', function (event, title, content) {
dialog.showErrorBox(title, content)
})

ipcMain.on('save-file', function () {
var metadata = userConfig.getSettings('metadata')
var ext = metadata ? metadata.dataset_id : 'mapeodata'
Expand Down
10 changes: 7 additions & 3 deletions src/renderer/components/dialogs/ImportMapStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const m = defineMessages({
importErrorTitle: 'Background Maps Import Error',
// Description of map import error
importErrorDescription:
'There was an error importing the background maps. Please try again.',
'There was an error importing the background maps. Please try again. Error message:',
// Label of 'Import File' button
importFile: 'Import File'
})
Expand Down Expand Up @@ -64,9 +64,13 @@ export const ImportMapStyleDialog = ({ open, close, refetch }) => {
onError(err)
}

function onError (err) {
async function onError (err) {
console.log({ err })
// remote.dialog.showErrorBox(t(m.importErrorTitle), t(m.importErrorDescription) + ': ' + err)
ipcRenderer.send(
'show-error-dialog',
t(m.importErrorTitle),
`${t(m.importErrorDescription)} ${err}`
)
}
}

Expand Down

0 comments on commit 3bbef99

Please sign in to comment.