Skip to content

chore: update Promise.reject()(s) across codebase to throw Error("message"), instead of regular string #5144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0e05529
chore: updated ActionSheet on Promise.reject
jimezesinachi Jan 21, 2024
14781f1
chore: updated AccessSchedule's Promise.reject()
jimezesinachi Jan 21, 2024
6483482
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Feb 12, 2024
abafb12
Merge branch 'master' of github.com:jimezesinachi/jellyfin-web into c…
jimezesinachi Sep 7, 2024
333a410
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Sep 21, 2024
cf72a41
commit first set of changes
jimezesinachi Jan 20, 2025
b533290
Merge remote-tracking branch 'upstream/master' into chore/refactor-pr…
jimezesinachi Jan 20, 2025
3aaaeef
updat e second set fo fixes
jimezesinachi Jan 20, 2025
66a4f68
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Feb 3, 2025
fc6f93d
Merge remote-tracking branch 'origin/master' into chore/refactor-prom…
jimezesinachi Apr 29, 2025
6a8ff5e
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Apr 30, 2025
b280735
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Apr 30, 2025
3286190
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Jun 6, 2025
fb5b217
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Jul 2, 2025
63267dc
revert cases where we already returned a value when rejecting
jimezesinachi Jul 16, 2025
cbb41e1
Merge branch 'chore/refactor-promise-rejections-to-throw-error' of gi…
jimezesinachi Jul 16, 2025
7b2c889
Merge branch 'master' into chore/refactor-promise-rejections-to-throw…
jimezesinachi Jul 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/accessSchedule/accessSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function show(options) {
if (dlg.submitted) {
resolve(options.schedule);
} else {
reject();
reject(new Error('AccessSchedule closed without resolving'));
}
});
dlg.querySelector('.btnCancel').addEventListener('click', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/collectionEditor/collectionEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class CollectionEditor {
return Promise.resolve();
}

return Promise.reject();
return Promise.reject(new Error('CollectionEditorError'));
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function showDialog(options = { dialogOptions: {}, buttons: [] }) {
if (dialogResult) {
return dialogResult;
} else {
return Promise.reject();
return Promise.reject(new Error('ShowDialogError'));
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/directorybrowser/directorybrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ function validatePath(path, validateWriteable, apiClient) {
if (response) {
if (response.status === 404) {
alertText(globalize.translate('PathNotFound'));
return Promise.reject();
return Promise.reject(new Error('PathNotFoundError'));
}
if (response.status === 500) {
if (validateWriteable) {
alertText(globalize.translate('WriteAccessRequired'));
} else {
alertText(globalize.translate('PathNotFound'));
}
return Promise.reject();
return Promise.reject(new Error('ValidatePathError'));
}
}
return Promise.resolve();
Expand Down
2 changes: 1 addition & 1 deletion src/components/guide/guide-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function showEditor(options) {
if (settingsChanged) {
resolve();
} else {
reject();
reject(new Error('ShowEditorError'));
}
});

Expand Down
8 changes: 4 additions & 4 deletions src/components/htmlMediaHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function handleHlsJsMediaError(instance, reject) {
console.error('cannot recover, last media error recovery failed ...');

if (reject) {
reject();
reject(new Error('HlsJsMediaError'));
} else {
onErrorInternal(instance, MediaError.FATAL_HLS_ERROR);
}
Expand Down Expand Up @@ -214,7 +214,7 @@ export function playWithPromise(elem, onErrorFn) {
});
} catch (err) {
console.error('error calling video.play: ' + err);
return Promise.reject();
return Promise.reject(new Error('VideoPlayError'));
}
}

Expand Down Expand Up @@ -263,7 +263,7 @@ export function bindEventsToHlsPlayer(instance, hls, elem, onErrorFn, resolve, r
hls.on(Hls.Events.MANIFEST_PARSED, function () {
playWithPromise(elem, onErrorFn).then(resolve, function () {
if (reject) {
reject();
reject(new Error('BindEventsToHlsPlayerError'));
reject = null;
}
});
Expand Down Expand Up @@ -328,7 +328,7 @@ export function bindEventsToHlsPlayer(instance, hls, elem, onErrorFn, resolve, r
hls.destroy();

if (reject) {
reject();
reject(new Error('HlsError'));
reject = null;
} else {
onErrorInternal(instance, MediaError.FATAL_HLS_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/components/imageDownloader/imageDownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function onDialogClosed() {
if (hasChanges) {
currentResolve();
} else {
currentReject();
currentReject(new Error('OnDialogClosedError'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/imageeditor/imageeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function showEditor(options, resolve, reject) {
if (hasChanges) {
resolve();
} else {
reject();
reject(new Error('ShowEditorError'));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/itemContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ function executeCommand(item, id, options) {
deleteSeriesTimer(apiClient, item, resolve, id);
break;
default:
reject();
reject(new Error('ExecuteCommandError'));
break;
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/itemidentifier/itemidentifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ function onDialogClosed() {
if (hasChanges) {
currentResolve();
} else {
currentReject();
currentReject(new Error('OnDialogClosedError'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/lyricseditor/lyricseditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function showEditorInternal(itemId, serverId) {
if (hasChanges) {
resolve();
} else {
reject();
reject(new Error('ShowEditorInternalError'));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/metadataEditor/personEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function show(person) {
if (submitted) {
resolve(person);
} else {
reject();
reject(new Error('PersonEditorError'));
}
});

Expand Down
18 changes: 9 additions & 9 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ function getOptimalMediaSource(apiClient, item, versions) {
});

if (!promises.length) {
return Promise.reject();
return Promise.reject(new Error('GetOptimalMediaSourceError'));
}

return Promise.all(promises).then(function (results) {
Expand Down Expand Up @@ -2286,7 +2286,7 @@ export class PlaybackManager {
// If it's still null then there's nothing to play
if (!firstItem) {
showPlaybackInfoErrorMessage(self, `PlaybackError.${MediaError.NO_MEDIA_ERROR}`);
return Promise.reject();
return Promise.reject(new Error(MediaError.NO_MEDIA_ERROR));
}

if (firstItem.MediaType === 'Photo' || firstItem.MediaType === 'Book') {
Expand Down Expand Up @@ -2335,7 +2335,7 @@ export class PlaybackManager {
if (item.IsPlaceHolder) {
loading.hide();
showPlaybackInfoErrorMessage(self, 'PlaybackErrorPlaceHolder');
return Promise.reject();
return Promise.reject(new Error('PlaybackInfoError'));
}

// Normalize defaults to simplfy checks throughout the process
Expand Down Expand Up @@ -2384,7 +2384,7 @@ export class PlaybackManager {
function onInterceptorRejection() {
cancelPlayback();

return Promise.reject();
return Promise.reject(new Error('InterceptorRejectionError'));
}

function onPlaybackRejection(e) {
Expand All @@ -2402,7 +2402,7 @@ export class PlaybackManager {

showPlaybackInfoErrorMessage(self, displayErrorCode);

return Promise.reject();
return Promise.reject(new Error('PlaybackRejectionError'));
}

function destroyPlayer(player) {
Expand Down Expand Up @@ -2952,11 +2952,11 @@ export class PlaybackManager {
}
} else {
showPlaybackInfoErrorMessage(self, `PlaybackError.${MediaError.NO_MEDIA_ERROR}`);
return Promise.reject();
return Promise.reject(new Error('GetOptimalMediaSourceError'));
}
});
} else {
return Promise.reject();
return Promise.reject(new Error('GetPlaybackInfoError'));
}
});
}
Expand Down Expand Up @@ -3737,7 +3737,7 @@ export class PlaybackManager {
const nextItem = this._playQueueManager.getNextItemInfo();

if (!nextItem?.item) {
return Promise.reject();
return Promise.reject(new Error('GetNextItemError'));
}

const apiClient = ServerConnections.getApiClient(nextItem.item.ServerId);
Expand Down Expand Up @@ -3907,7 +3907,7 @@ export class PlaybackManager {
});
}

return Promise.reject();
return Promise.reject(new Error('PlayTrailersError'));
}

getSubtitleUrl(textStream, serverId) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/playback/playersettingsmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function showAspectRatioMenu(player, btn) {
return Promise.resolve();
}

return Promise.reject();
return Promise.reject(new Error('ShowAspectRatioMenuError'));
});
}

Expand All @@ -167,7 +167,7 @@ function showPlaybackRateMenu(player, btn) {
return Promise.resolve();
}

return Promise.reject();
return Promise.reject(new Error('ShowPlaybackRateMenuError'));
});
}

Expand Down Expand Up @@ -282,7 +282,7 @@ function handleSelectedOption(id, options, player) {
break;
}

return Promise.reject();
return Promise.reject(new Error('HandleSelectedOptionError'));
}

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/components/playlisteditor/playlisteditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export class PlaylistEditor {
return Promise.resolve();
}

return Promise.reject(new Error());
return Promise.reject(new Error('ShowPlaylistEditorError'));
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompt/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default (() => {
if (submitValue) {
return submitValue;
} else {
return Promise.reject();
return Promise.reject(new Error('PromptError'));
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/recordingcreator/recordingcreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function showEditor(itemId, serverId) {
if (currentRecordingFields?.hasChanged()) {
resolve();
} else {
reject();
reject(new Error('CurrentRecordingFieldsError'));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/recordingcreator/recordinghelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerI
// schedule recording
return createRecording(apiClient, programId);
} else {
return Promise.reject();
return Promise.reject(new Error('ToggleRecordingError'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/recordingcreator/seriesrecordingeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function showEditor(itemId, serverId, options) {
deleted: recordingDeleted
});
} else {
reject();
reject(new Error('RecordingUpdatedError'));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/sortmenu/sortmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SortMenu {
return;
}

reject();
reject(new Error('SortMenuError'));
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/subtitleeditor/subtitleeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ function showEditorInternal(itemId, serverId) {
if (hasChanges) {
resolve();
} else {
reject();
reject(new Error('SubtitleEditorError'));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/tunerPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function TunerPicker() {
return Promise.resolve(deviceResult);
}

return Promise.reject();
return Promise.reject(new Error('TunerPickerError'));
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/viewContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export function tryRestoreView(options) {
}
}

return Promise.reject();
return Promise.reject(new Error('TryRestoreViewError'));
}

function triggerDestroy(view) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/bookPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export class BookPlayer {
this.bindEvents();

return this.rendition.book.locations.generate(1024).then(async () => {
if (this.cancellationToken) reject();
if (this.cancellationToken) reject(new Error('GenerateLocationsError'));

const percentageTicks = options.startPositionTicks / 10000000;
if (percentageTicks !== 0.0) {
Expand All @@ -380,7 +380,7 @@ export class BookPlayer {
});
}, () => {
console.error('failed to display epub');
return reject();
return reject(new Error('SetCurrentSrcError'));
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/chromecastPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function sendConnectionResult(isOk) {
resolve();
}
} else if (reject) {
reject();
reject(new Error('SendConnectionResultError'));
} else {
playbackManager.removeActivePlayer(PlayerName);
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/htmlAudioPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function requireHlsPlayer(callback) {

function enableHlsPlayer(url, item, mediaSource, mediaType) {
if (!htmlMediaHelper.enableHlsJsPlayer(mediaSource.RunTimeTicks, mediaType)) {
return Promise.reject();
return Promise.reject(new Error('EnableHlsPlayerError'));
}

if (url.indexOf('.m3u8') !== -1) {
Expand All @@ -80,7 +80,7 @@ function enableHlsPlayer(url, item, mediaSource, mediaType) {
if (contentType === 'application/vnd.apple.mpegurl' || contentType === 'application/x-mpegurl') {
resolve();
} else {
reject();
reject(new Error('HlsPlayerContentTypeError'));
}
}, reject);
});
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/playAccessValidation/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class PlayAccessValidation {

// reject but don't show an error message
if (!options.fullscreen) {
return Promise.reject();
return Promise.reject(new Error('PlayAccessValidationInterceptError'));
}

return showErrorMessage()
.finally(() => Promise.reject());
.finally(() => Promise.reject(new Error('ShowPlayAccessValidationInterceptError')));
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/syncPlay/core/QueueCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class QueueCore {
startPlayback(apiClient) {
if (!this.manager.isFollowingGroupPlayback()) {
console.debug('SyncPlay startPlayback: ignoring, not following playback.');
return Promise.reject();
return Promise.reject(new Error('IsNotFollowingGroupPlaybackError'));
}

if (this.isPlaylistEmpty()) {
Expand Down
Loading
Loading