Skip to content

Commit

Permalink
improve error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Last-Order committed Nov 13, 2021
1 parent 485633c commit a04bac2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kkr",
"version": "1.2.7",
"version": "1.2.8",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/core/services/api/youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import axios from "axios";
import * as ErrorMessages from "../../messages/error";

export class ParseError extends Error {}
export class VideoPlayabilityStatusError extends Error {}
class YouTubeService {
static getVideoIdByUrl(videoUrl: string) {
let videoId;
Expand Down Expand Up @@ -42,6 +43,12 @@ class YouTubeService {
}
const title = playerResponse?.videoDetails?.title as string;
if (!playerResponse.streamingData) {
const errorReason =
playerResponse?.playabilityStatus?.errorScreen?.playerErrorMessageRenderer?.subreason?.simpleText ||
playerResponse?.playabilityStatus?.errorScreen?.playerErrorMessageRenderer?.subreason?.runs?.[0]?.text;
if (errorReason) {
throw new VideoPlayabilityStatusError(errorReason);
}
throw new ParseError(ErrorMessages.NOT_A_LIVE_STREAM);
}
const mpdUrl = playerResponse.streamingData.dashManifestUrl as string;
Expand Down

0 comments on commit a04bac2

Please sign in to comment.