Skip to content

Commit 6af2eef

Browse files
committed
Emit console.trace instead of throwing errors for non-critical stuff
Fixes #7 The issue is here that a promise is usually expected, so I cannot just return Promise.ject() with an empty error, because this also results in a red error for the promise (with the worse error message "undefined"). Thus I've just made it to return a successful promise or undefined. I've also changed the similar uncritical error when tips should be shown according to gobal randomize, but no tip could be shown due to other factors, so there is no tip to be shown. Console.trace is BTW well-supported across browsers: https://developer.mozilla.org/en-US/docs/Web/API/console/trace#browser_compatibility
1 parent 0eaaf04 commit 6af2eef

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

RandomTips.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ export function setContext(newContext) {
294294
export async function showRandomTip() {
295295
// only try to select tip, if one is even available
296296
if (tips.length === 0) {
297-
console.info("no tips to show available anymore");
298-
return Promise.reject(new Error("no tips to show available anymore"));
297+
console.trace("no tips to show available anymore");
298+
return;
299299
}
300300

301301
// randomly select element
@@ -322,15 +322,15 @@ export async function showRandomTip() {
322322
* Shows the random tip only randomly so the user is not annoyed.
323323
*
324324
* @public
325-
* @returns {Promise}
325+
* @returns {Promise | undefined}
326326
*/
327327
export function showRandomTipIfWanted() {
328328
saveConfig();
329329

330330
// randomize tip showing in general
331331
if (!randomizePassed(GLOBAL_RANDOMIZE)) {
332-
console.info("show no random tip, because randomize did not pass");
333-
return Promise.reject(new Error("show no random tip, because randomize did not pass"));
332+
console.trace("show no random tip, because randomize did not pass");
333+
return;
334334
}
335335

336336
return showRandomTip();

0 commit comments

Comments
 (0)