mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
refactor: no throw literal in utilsController
This commit is contained in:
parent
b5af733dc2
commit
1142b64e3c
@ -218,7 +218,7 @@ self.generateThumbs = async (name, extname, force) => {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Re-throw error
|
// Re-throw non-ENOENT error
|
||||||
if (error.code !== 'ENOENT') throw error
|
if (error.code !== 'ENOENT') throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,12 +265,12 @@ self.generateThumbs = async (name, extname, force) => {
|
|||||||
|
|
||||||
const duration = parseInt(metadata.format.duration)
|
const duration = parseInt(metadata.format.duration)
|
||||||
if (isNaN(duration)) {
|
if (isNaN(duration)) {
|
||||||
throw 'Warning: File does not have valid duration metadata'
|
throw new Error('File does not have valid duration metadata')
|
||||||
}
|
}
|
||||||
|
|
||||||
const videoStream = metadata.streams && metadata.streams.find(s => s.codec_type === 'video')
|
const videoStream = metadata.streams && metadata.streams.find(s => s.codec_type === 'video')
|
||||||
if (!videoStream || !videoStream.width || !videoStream.height) {
|
if (!videoStream || !videoStream.width || !videoStream.height) {
|
||||||
throw 'Warning: File does not have valid video stream metadata'
|
throw new Error('File does not have valid video stream metadata')
|
||||||
}
|
}
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
@ -297,7 +297,7 @@ self.generateThumbs = async (name, extname, force) => {
|
|||||||
return true
|
return true
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
throw error || 'Warning: FFMPEG exited with empty output file'
|
throw error || new Error('FFMPEG exited with empty output file')
|
||||||
} else {
|
} else {
|
||||||
throw error || err
|
throw error || err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user