🧑‍💻 Improve record error debugging

This commit is contained in:
Yann Bertrand 2022-08-17 17:20:51 +02:00
parent e6a2962ef1
commit 70c608b9a7
2 changed files with 13 additions and 11 deletions

View file

@ -36,7 +36,6 @@ module.exports = async (files) => {
) )
} catch (error) { } catch (error) {
if (error.code === 'RECORDER_TIMEOUT') { if (error.code === 'RECORDER_TIMEOUT') {
console.error(error.message)
console.info('The recorder timed out.') console.info('The recorder timed out.')
console.info( console.info(
"You probably need to activate the screen recording feature for the terminal you're using." "You probably need to activate the screen recording feature for the terminal you're using."
@ -45,11 +44,12 @@ module.exports = async (files) => {
"You'll find that settings under: System Parameters > Security & Confidentiality > Confidentiality > Screen recording" "You'll find that settings under: System Parameters > Security & Confidentiality > Confidentiality > Screen recording"
) )
} else if (error.code === 'ENOTDIR') { } else if (error.code === 'ENOTDIR') {
console.error(error.message)
console.info('A mandatory folder was not found.') console.info('A mandatory folder was not found.')
} else { } else {
console.error('An error occured while recording', error) console.error('An error occured while recording')
} }
throw error
} }
} }

View file

@ -87,6 +87,7 @@ function resizeVideo(input, output) {
console.info(' Resizing video') console.info(' Resizing video')
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const ffmpegRawLogs = []
const ffmpeg = spawn('ffmpeg', [ const ffmpeg = spawn('ffmpeg', [
'-i', '-i',
input, input,
@ -104,15 +105,16 @@ function resizeVideo(input, output) {
output, output,
]) ])
if (process.env.NODE_ENV === 'DEBUG') { ffmpeg.stderr.on('data', (message) =>
ffmpeg.stderr.on('data', function (message) { ffmpegRawLogs.push(message.toString('utf8'))
console.debug(`${message}`) )
})
}
ffmpeg.on('exit', (ffmpegExitCode) => { ffmpeg.on('exit', (ffmpegExitCode) => {
if (ffmpegExitCode === '1') { if (process.env.NODE_ENV === 'DEBUG') {
return reject('ffmpeg') console.debug(ffmpegRawLogs.join('\n'))
}
if (ffmpegExitCode !== 0) {
return reject(ffmpegRawLogs.join('\n'))
} }
resolve() resolve()