jwplayer-errors

2.0.0 • Public • Published

JWPlayer Errors

This repo contains a standardized, numerical set of errors used by JWPlayer and its plugins.

Installation

npm i -D jwplayer-errors

API Docs

Here!

Usage

Importing

Each module is a named export:

build, Category, Code, Severity, Data

You can import them all with the following syntax:

import * as JWError from 'jwplayer-errors;'

Or individually:

import Category from 'jwplayer-errors;'

Building errors

Errors are composed of a Category, Code, Severity, and an optional Data object, which are passed into the build function with the following signature:

build(category, code, severity, data)

The build function uses these arguments to generate a standardized error message, which it returns along with the numerical values (while omitting the data object):

{
    category,
    code,
    severity,
    message
}

Important!: The data argument must be created with a factory function from the JWError.Data module. Data arguments are expected to conform to a certain structure.

Example

import * as JWError from `jwplayer-errors`;

const networkErrorData = JWError.Data.Network('https://jwplayer.com', 404, 'Not found');

const error = JWError.build(
    JWError.Category.NETWORK,
    JWError.Code.BAD_HTTP_STATUS,
    JWError.Severity.FATAL,
    networkErrorData
);

API

Readme

Keywords

none

Package Sidebar

Install

npm i jwplayer-errors

Weekly Downloads

0

Version

2.0.0

License

CC-BY-NC-SA-3.0

Last publish

Collaborators

  • vdnkh