See: https://github.com/feross/capture-frame Capture video screenshot from a `<video>` tag (at the current time) Changes from our version: - Added tests in Chrome/Firefox browsers. - Use built-in TypeError (which is meant for bad arguments) instead of custom IllegalArgumentError.
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
const ExtendableError = require('es6-error')
|
|
|
|
/* Generic errors */
|
|
|
|
class CastingError extends ExtendableError {}
|
|
class PlaybackError extends ExtendableError {}
|
|
class SoundError extends ExtendableError {}
|
|
class TorrentError extends ExtendableError {}
|
|
|
|
/* Playback */
|
|
|
|
class UnplayableTorrentError extends PlaybackError {
|
|
constructor () { super('Can\'t play any files in torrent') }
|
|
}
|
|
|
|
class UnplayableFileError extends PlaybackError {
|
|
constructor () { super('Can\'t play that file') }
|
|
}
|
|
|
|
class PlaybackTimedOutError extends PlaybackError {
|
|
constructor () { super('Playback timed out. Try again.') }
|
|
}
|
|
|
|
/* Sound */
|
|
|
|
class InvalidSoundNameError extends SoundError {
|
|
constructor (name) { super(`Invalid sound name: ${name}`) }
|
|
}
|
|
|
|
/* Torrent */
|
|
|
|
class TorrentKeyNotFoundError extends TorrentError {
|
|
constructor (torrentKey) { super(`Can't resolve torrent key ${torrentKey}`) }
|
|
}
|
|
|
|
class InvalidTorrentError extends TorrentError {}
|
|
|
|
module.exports = {
|
|
CastingError,
|
|
PlaybackError,
|
|
SoundError,
|
|
TorrentError,
|
|
UnplayableTorrentError,
|
|
UnplayableFileError,
|
|
PlaybackTimedOutError,
|
|
InvalidSoundNameError,
|
|
TorrentKeyNotFoundError,
|
|
InvalidTorrentError
|
|
}
|