diff options
author | 2020-04-20 23:12:46 +0200 | |
---|---|---|
committer | 2020-04-20 23:12:46 +0200 | |
commit | 453d3f8566695ce1ea7edd729fb319084bdb7fc2 (patch) | |
tree | 14933512dbc7537b3e20b8ed67b486406a0d981b /source/libs/utils.ts | |
parent | 65aeb52a3992aac49ab38ed4eb15de9bcae67359 (diff) | |
download | refined-github-453d3f8566695ce1ea7edd729fb319084bdb7fc2.tar.gz refined-github-453d3f8566695ce1ea7edd729fb319084bdb7fc2.tar.zst refined-github-453d3f8566695ce1ea7edd729fb319084bdb7fc2.zip |
Meta: Improve types (#3006)
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r-- | source/libs/utils.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/libs/utils.ts b/source/libs/utils.ts index 364c271d..dc1aeb35 100644 --- a/source/libs/utils.ts +++ b/source/libs/utils.ts @@ -4,24 +4,28 @@ import stripIndent from 'strip-indent'; import {isRepo, isPR, isIssue} from './page-detect'; import compareVersions from 'tiny-version-compare'; -export function logError(featureName: FeatureName, error: Error | string, ...extras: unknown[]): void { +export function logError(id: FeatureID, error: Error | string, ...extras: unknown[]): void { + if (error instanceof TypeError && error.message === 'Object(...)(...) is null') { + error.message = 'The element wasn’t found, the selector needs to be updated.'; + } + const message = typeof error === 'string' ? error : error.message; if (message.includes('token')) { - console.log(`ℹ️ Refined GitHub → ${featureName} →`, message); + console.log(`ℹ️ Refined GitHub → ${id} →`, message); return; } // Don't change this to `throw Error` because Firefox doesn't show extensions' errors in the console. // Use `return` after calling this function. console.error( - `❌ Refined GitHub → ${featureName} →`, + `❌ Refined GitHub → ${id} →`, error, ...extras, stripIndent(` Search issue: https://github.com/sindresorhus/refined-github/issues?q=is%3Aissue+${encodeURIComponent(message)} - Open an issue: https://github.com/sindresorhus/refined-github/issues/new?labels=bug&template=bug_report.md&title=${encodeURIComponent(`\`${featureName}\`: ${message}`)} + Open an issue: https://github.com/sindresorhus/refined-github/issues/new?labels=bug&template=bug_report.md&title=${encodeURIComponent(`\`${id}\`: ${message}`)} `) ); } |