Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Manage message error on generating ZIP #1624

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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