Move error definitions to errors.js (#898)
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
module.exports = captureVideoFrame
|
||||
|
||||
const {IllegalArgumentError} = require('./errors')
|
||||
|
||||
function captureVideoFrame (video, format) {
|
||||
if (typeof video === 'string') {
|
||||
video = document.querySelector(video)
|
||||
}
|
||||
|
||||
if (video == null || video.nodeName !== 'VIDEO') {
|
||||
throw new Error('First argument must be a <video> element or selector')
|
||||
throw new IllegalArgumentError('First argument must be a <video> element or selector')
|
||||
}
|
||||
|
||||
if (format == null) {
|
||||
@@ -14,7 +16,7 @@ function captureVideoFrame (video, format) {
|
||||
}
|
||||
|
||||
if (format !== 'png' && format !== 'jpg' && format !== 'webp') {
|
||||
throw new Error('Second argument must be one of "png", "jpg", or "webp"')
|
||||
throw new IllegalArgumentError('Second argument must be one of "png", "jpg", or "webp"')
|
||||
}
|
||||
|
||||
const canvas = document.createElement('canvas')
|
||||
|
||||
Reference in New Issue
Block a user