mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-22 14:08:06 +00:00
chore: add more metadata to the error class
This commit is contained in:
@@ -4,14 +4,16 @@ const Crypto = require('crypto');
|
||||
const UserAgent = require('user-agents');
|
||||
const Flatten = require('flat');
|
||||
|
||||
function InnertubeError(message, info) {
|
||||
this.info = info || {};
|
||||
this.stack = new Error(message).stack;
|
||||
this.message = message;
|
||||
}
|
||||
class InnertubeError extends Error {
|
||||
constructor (message, info) {
|
||||
super(message);
|
||||
|
||||
info && (this.info = info);
|
||||
|
||||
InnertubeError.prototype = Object.create(Error.prototype);
|
||||
InnertubeError.prototype.constructor = InnertubeError;
|
||||
this.date = new Date();
|
||||
this.version = require('../../package.json').version;
|
||||
}
|
||||
}
|
||||
|
||||
class ParsingError extends InnertubeError {};
|
||||
class DownloadError extends InnertubeError {};
|
||||
@@ -138,7 +140,7 @@ function refineNTokenData(data) {
|
||||
.replace(/""/g, '').replace(/length]\)}"/g, 'length])}');
|
||||
}
|
||||
|
||||
const errors = { UnavailableContentError, ParsingError, DownloadError, InnertubeError, MissingParamError, NoStreamingDataError };
|
||||
const errors = { InnertubeError, UnavailableContentError, ParsingError, DownloadError, InnertubeError, MissingParamError, NoStreamingDataError };
|
||||
const functions = { findNode, getRandomUserAgent, generateSidAuth, generateRandomString, getStringBetweenStrings, camelToSnake, timeToSeconds, refineNTokenData };
|
||||
|
||||
module.exports = { ...functions, ...errors };
|
||||
Reference in New Issue
Block a user