mirror of
https://github.com/xodio/xod.git
synced 2026-03-25 10:06:55 +01:00
fix(xod-client-electron): make proper errors for different steps of upload process
This commit is contained in:
@@ -209,6 +209,30 @@ const patchFqbnWithOptions = board => {
|
||||
)(selectedBoardOptions);
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
//
|
||||
// Error wrappers
|
||||
//
|
||||
// =============================================================================
|
||||
|
||||
// :: Error -> RejectedPromise Error
|
||||
const wrapCompileError = err =>
|
||||
Promise.reject(
|
||||
createError('COMPILE_TOOL_ERROR', {
|
||||
message: err.message,
|
||||
code: err.code,
|
||||
})
|
||||
);
|
||||
|
||||
// :: Error -> RejectedPromise Error
|
||||
const wrapUploadError = err =>
|
||||
Promise.reject(
|
||||
createError('UPLOAD_TOOL_ERROR', {
|
||||
message: err.message,
|
||||
code: err.code,
|
||||
})
|
||||
);
|
||||
|
||||
// =============================================================================
|
||||
//
|
||||
// Handlers
|
||||
@@ -369,18 +393,20 @@ const uploadThroughCloud = async (onProgress, cli, payload) => {
|
||||
message: CODE_COMPILED,
|
||||
tab: 'compiler',
|
||||
});
|
||||
const uploadLog = await cli.upload(
|
||||
stdout =>
|
||||
onProgress({
|
||||
percentage: 60,
|
||||
message: stdout,
|
||||
tab: 'uploader',
|
||||
}),
|
||||
payload.port.comName,
|
||||
payload.board.fqbn,
|
||||
sketchName,
|
||||
false
|
||||
);
|
||||
const uploadLog = await cli
|
||||
.upload(
|
||||
stdout =>
|
||||
onProgress({
|
||||
percentage: 60,
|
||||
message: stdout,
|
||||
tab: 'uploader',
|
||||
}),
|
||||
payload.port.comName,
|
||||
payload.board.fqbn,
|
||||
sketchName,
|
||||
false
|
||||
)
|
||||
.catch(wrapUploadError);
|
||||
onProgress({
|
||||
percentage: 100,
|
||||
message: '',
|
||||
@@ -416,17 +442,19 @@ const uploadThroughUSB = async (onProgress, cli, payload) => {
|
||||
tab: 'compiler',
|
||||
});
|
||||
|
||||
const compileLog = await cli.compile(
|
||||
stdout =>
|
||||
onProgress({
|
||||
percentage: 40,
|
||||
message: stdout,
|
||||
tab: 'compiler',
|
||||
}),
|
||||
payload.board.fqbn,
|
||||
sketchName,
|
||||
false
|
||||
);
|
||||
const compileLog = await cli
|
||||
.compile(
|
||||
stdout =>
|
||||
onProgress({
|
||||
percentage: 40,
|
||||
message: stdout,
|
||||
tab: 'compiler',
|
||||
}),
|
||||
payload.board.fqbn,
|
||||
sketchName,
|
||||
false
|
||||
)
|
||||
.catch(wrapCompileError);
|
||||
|
||||
onProgress({
|
||||
percentage: 50,
|
||||
@@ -434,18 +462,20 @@ const uploadThroughUSB = async (onProgress, cli, payload) => {
|
||||
tab: 'uploader',
|
||||
});
|
||||
|
||||
const uploadLog = await cli.upload(
|
||||
stdout =>
|
||||
onProgress({
|
||||
percentage: 60,
|
||||
message: stdout,
|
||||
tab: 'uploader',
|
||||
}),
|
||||
payload.port.comName,
|
||||
payload.board.fqbn,
|
||||
sketchName,
|
||||
false
|
||||
);
|
||||
const uploadLog = await cli
|
||||
.upload(
|
||||
stdout =>
|
||||
onProgress({
|
||||
percentage: 60,
|
||||
message: stdout,
|
||||
tab: 'uploader',
|
||||
}),
|
||||
payload.port.comName,
|
||||
payload.board.fqbn,
|
||||
sketchName,
|
||||
false
|
||||
)
|
||||
.catch(wrapUploadError);
|
||||
onProgress({
|
||||
percentage: 100,
|
||||
message: '',
|
||||
|
||||
@@ -4,8 +4,14 @@ export default {
|
||||
note: `Cloud compilation does not support ${boardName} yet.`,
|
||||
solution: 'Try to compile it on your own computer',
|
||||
}),
|
||||
COMPILE_TOOL_ERROR: ({ message }) => ({
|
||||
title: 'Compilation failed',
|
||||
note: `Command ${message}`,
|
||||
solution:
|
||||
'The generated C++ code contains errors. It can be due to a bad node implementation or if your board is not compatible with XOD runtime code. The original compiler error message is above. Fix C++ errors to continue. If you believe it is a bug, report the problem to XOD developers.',
|
||||
}),
|
||||
UPLOAD_TOOL_ERROR: ({ message }) => ({
|
||||
title: 'Upload tool exited with error',
|
||||
title: 'Upload failed',
|
||||
note: `Command ${message}`,
|
||||
solution:
|
||||
'Make sure the board is connected, the cable is working, the board model set correctly, the upload port belongs to the board, the board drivers are installed, the upload options (if any) match your board specs.',
|
||||
|
||||
@@ -331,15 +331,7 @@ class App extends client.App {
|
||||
board,
|
||||
port,
|
||||
}
|
||||
).catch(err => {
|
||||
console.error(err); // eslint-disable-line no-console
|
||||
return Promise.reject(
|
||||
createError('UPLOAD_TOOL_ERROR', {
|
||||
message: err.message,
|
||||
code: err.code,
|
||||
})
|
||||
);
|
||||
})
|
||||
)
|
||||
)
|
||||
.then(() => proc.success())
|
||||
.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user