Skip to content

Commit

Permalink
uploadItemSubtitle: update error messages, remove unnecessary 'this' …
Browse files Browse the repository at this point in the history
…reference
  • Loading branch information
redSpoutnik committed Jun 1, 2020
1 parent 73fbde0 commit d3b18b8
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2033,19 +2033,19 @@ class ApiClient {

uploadItemSubtitle(itemId, language, isForced, file) {
if (!itemId) {
throw new Error('null itemId');
throw new SyntaxError('Missing itemId');
}

if (!language) {
throw new Error('null language');
throw new SyntaxError('Missing language');
}

if (typeof isForced !== 'boolean') {
throw new Error('Invalid isForced value.');
throw new TypeError('Parameter isForced must be a boolean.');
}

if (!file) {
throw new Error('File must be a subtitle file.');
throw new SyntaxError('File must be a subtitle file.');
}

const format = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
Expand All @@ -2056,8 +2056,6 @@ class ApiClient {

let url = this.getUrl(`Videos/${itemId}/Subtitles`);

const instance = this;

return new Promise((resolve, reject) => {
const reader = new FileReader();

Expand All @@ -2074,8 +2072,7 @@ class ApiClient {
// Split by a comma to remove the url: prefix
const data = e.target.result.split(',')[1];

instance
.ajax({
this.ajax({
type: 'POST',
url,
data: {
Expand Down

0 comments on commit d3b18b8

Please sign in to comment.