-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: streaming events and errors (#1508)
- Loading branch information
Showing
25 changed files
with
1,550 additions
and
450 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
import videojs from 'video.js'; | ||
|
||
// https://www.w3.org/TR/WebIDL-1/#quotaexceedederror | ||
export const QUOTA_EXCEEDED_ERR = 22; | ||
|
||
export const getStreamingNetworkErrorMetadata = ({ requestType, request, error, parseFailure }) => { | ||
const isBadStatus = request.status < 200 || request.status > 299; | ||
const isFailure = request.status >= 400 && request.status <= 499; | ||
const errorMetadata = { | ||
uri: request.uri, | ||
requestType | ||
}; | ||
const isBadStatusOrParseFailure = (isBadStatus && !isFailure) || parseFailure; | ||
|
||
if (error && isFailure) { | ||
// copy original error and add to the metadata. | ||
errorMetadata.error = {...error}; | ||
errorMetadata.errorType = videojs.Error.NetworkRequestFailed; | ||
} else if (request.aborted) { | ||
errorMetadata.errorType = videojs.Error.NetworkRequestAborted; | ||
} else if (request.timedout) { | ||
errorMetadata.erroType = videojs.Error.NetworkRequestTimeout; | ||
} else if (isBadStatusOrParseFailure) { | ||
const errorType = parseFailure ? videojs.Error.NetworkBodyParserFailed : videojs.Error.NetworkBadStatus; | ||
|
||
errorMetadata.errorType = errorType; | ||
errorMetadata.status = request.status; | ||
errorMetadata.headers = request.headers; | ||
} | ||
|
||
return errorMetadata; | ||
}; |
Oops, something went wrong.