🧑‍💻 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) {
if (error.code === 'RECORDER_TIMEOUT') {
console.error(error.message)
console.info('The recorder timed out.')
console.info(
"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"
)
} else if (error.code === 'ENOTDIR') {
console.error(error.message)
console.info('A mandatory folder was not found.')
} 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')
return new Promise((resolve, reject) => {
const ffmpegRawLogs = []
const ffmpeg = spawn('ffmpeg', [
'-i',
input,
@ -104,15 +105,16 @@ function resizeVideo(input, output) {
output,
])
ffmpeg.stderr.on('data', (message) =>
ffmpegRawLogs.push(message.toString('utf8'))
)
ffmpeg.on('exit', (ffmpegExitCode) => {
if (process.env.NODE_ENV === 'DEBUG') {
ffmpeg.stderr.on('data', function (message) {
console.debug(`${message}`)
})
console.debug(ffmpegRawLogs.join('\n'))
}
ffmpeg.on('exit', (ffmpegExitCode) => {
if (ffmpegExitCode === '1') {
return reject('ffmpeg')
if (ffmpegExitCode !== 0) {
return reject(ffmpegRawLogs.join('\n'))
}
resolve()