Skip to content

Commit

Permalink
Merge pull request #1624 from oodamien
Browse files Browse the repository at this point in the history
* pr/1624:
  Improve error message in UI

Closes gh-1624
  • Loading branch information
mhalbritter committed Oct 31, 2024
2 parents b54c096 + e2af349 commit c706c45
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
41 changes: 23 additions & 18 deletions start-client/src/components/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ export default function Application() {
}
}, [dispatch, dispatchInitializr, windowsUtils.origin])

const onEscape = () => {
setBlob(null)
dispatch({
type: 'UPDATE',
payload: {
list: false,
share: false,
explore: false,
nav: false,
history: false,
},
})
}

const onSubmit = async () => {
if (generating || list) {
return
Expand All @@ -74,8 +88,10 @@ export default function Application() {
url,
values,
get(dependencies, 'list')
).catch(() => {
toast.error(`Could not connect to server. Please check your network.`)
).catch(err => {
toast.error(
err || `Could not connect to server. Please check your network.`
)
})
setGenerating(false)
if (project) {
Expand All @@ -91,8 +107,11 @@ export default function Application() {
url,
values,
get(dependencies, 'list')
).catch(() => {
toast.error(`Could not connect to server. Please check your network.`)
).catch(err => {
toast.error(
err || `Could not connect to server. Please check your network.`
)
onEscape()
})
setBlob(project)
}
Expand All @@ -101,20 +120,6 @@ export default function Application() {
dispatch({ type: 'UPDATE', payload: { share: true } })
}

const onEscape = () => {
setBlob(null)
dispatch({
type: 'UPDATE',
payload: {
list: false,
share: false,
explore: false,
nav: false,
history: false,
},
})
}

return (
<>
<BodyClassName className={theme} />
Expand Down
10 changes: 8 additions & 2 deletions start-client/src/components/utils/ApiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const parseParams = (values, queryParams, lists) => {
const depsWarning = []
const newVal = value
.split(',')
.filter(item => !!item)
.filter(item => !!item)
.map(item => {
const dep = get(lists, 'dependencies').find(
d => d.id === item.trim()
Expand Down Expand Up @@ -301,7 +301,13 @@ export const getProject = function getProject(url, values, config) {
resolve(response.blob())
return
}
reject()
try {
response.json().then(res => {
reject(res?.message || '')
})
} catch (e) {
reject()
}
},
() => {
reject()
Expand Down
9 changes: 9 additions & 0 deletions start-client/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ const config = {
}, 800)
})
devServer.app.get('/starter.zip', function (req, res) {
// 500 errors
// res.status(500).json({
// timestamp: '2022-09-05T14:39:37.471+00:00',
// status: 500,
// error: 'Internal Server Error',
// message:
// 'Malformed input or input contains unmappable characters: MixérApplication.java',
// path: '/starter.zip',
// })
fs.readFile(path.resolve('./dev/starter.mock.zip'), (err, data) => {
if (err) return sendError(err, res)
setTimeout(() => {
Expand Down

0 comments on commit c706c45

Please sign in to comment.