Skip to content

Commit

Permalink
Merge pull request #5734 from prsantos-com/sonarcloud-promise-rejection
Browse files Browse the repository at this point in the history
Use Error instead of literal for promise rejection
  • Loading branch information
thornbill authored Jul 26, 2024
2 parents 08bbcb0 + c3ad26e commit b9dea3a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = {
'operator-linebreak': ['error', 'before', { overrides: { '?': 'after', ':': 'after', '=': 'after' } }],
'padded-blocks': ['error', 'never'],
'prefer-const': ['error', { 'destructuring': 'all' }],
'prefer-promise-reject-errors': ['warn', { 'allowEmptyReject': true }],
'@typescript-eslint/prefer-for-of': ['error'],
'@typescript-eslint/prefer-optional-chain': ['error'],
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }],
Expand Down
2 changes: 1 addition & 1 deletion src/components/actionSheet/actionSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export function show(options: Options) {

resolve(selectedId);
} else {
reject('ActionSheet closed without resolving');
reject(new Error('ActionSheet closed without resolving'));
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2502,7 +2502,7 @@ class PlaybackManager {
return Promise.resolve()
.then(() => {
if (!isServerItem(item) || itemHelper.isLocalItem(item)) {
return Promise.reject('skip bitrate detection');
return Promise.reject(new Error('skip bitrate detection'));
}

return apiClient.getEndpointInfo()
Expand All @@ -2514,7 +2514,7 @@ class PlaybackManager {
});
}

return Promise.reject('skip bitrate detection');
return Promise.reject(new Error('skip bitrate detection'));
});
})
.catch(() => getSavedMaxStreamingBitrate(apiClient, mediaType));
Expand Down
2 changes: 1 addition & 1 deletion src/components/router/appRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class AppRouter {
if (firstResult.State === ConnectionState.ServerSignIn) {
const url = firstResult.ApiClient.serverAddress() + '/System/Info/Public';
fetch(url).then(response => {
if (!response.ok) return Promise.reject('fetch failed');
if (!response.ok) return Promise.reject(new Error('fetch failed'));
return response.json();
}).then(data => {
if (data !== null && data.StartupWizardCompleted === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/syncPlay/core/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function waitForEventOnce(emitter, eventType, timeout, rejectEventTypes)
let rejectTimeout;
if (timeout) {
rejectTimeout = setTimeout(() => {
reject('Timed out.');
reject(new Error('Timed out.'));
}, timeout);
}

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 @@ -123,7 +123,7 @@ class QueueCore {

if (!itemIds.length) {
if (this.lastPlayQueueUpdate && playQueueUpdate.LastUpdate.getTime() <= this.getLastUpdateTime()) {
return Promise.reject('Trying to apply old update');
return Promise.reject(new Error('Trying to apply old update'));
}

this.lastPlayQueueUpdate = playQueueUpdate;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/syncPlay/core/timeSync/TimeSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class TimeSync {
*/
requestPing() {
console.warn('SyncPlay TimeSync requestPing: override this method!');
return Promise.reject('Not implemented.');
return Promise.reject(new Error('Not implemented.'));
}

/**
Expand Down

0 comments on commit b9dea3a

Please sign in to comment.