summaryrefslogtreecommitdiff
path: root/source/libs/utils.ts
diff options
context:
space:
mode:
authorGravatar Federico Brigante <github@bfred.it> 2020-03-25 19:26:39 +0100
committerGravatar GitHub <noreply@github.com> 2020-03-25 19:26:39 +0100
commit84ad80d53a108c7daf7e5c25d5d5adf2bc1179b7 (patch)
treeefa6816026962d27cf4d43b3d212b8a3c43d4d73 /source/libs/utils.ts
parent09b6ffa6647e068707bff59c5a18eea67d1ba0fe (diff)
downloadrefined-github-84ad80d53a108c7daf7e5c25d5d5adf2bc1179b7.tar.gz
refined-github-84ad80d53a108c7daf7e5c25d5d5adf2bc1179b7.tar.zst
refined-github-84ad80d53a108c7daf7e5c25d5d5adf2bc1179b7.zip
Improve error UX (#2919)
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r--source/libs/utils.ts29
1 files changed, 10 insertions, 19 deletions
diff --git a/source/libs/utils.ts b/source/libs/utils.ts
index 38d4b6b9..68ff552b 100644
--- a/source/libs/utils.ts
+++ b/source/libs/utils.ts
@@ -8,14 +8,16 @@ export function logError(featureName: typeof __featureName__, error: Error | str
const message = typeof error === 'string' ? error : error.message;
// 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: feature \`${featureName}\`\n\n`, error, ...extras, stripIndent(`
-
- Search for open issues:
- https://github.com/sindresorhus/refined-github/issues?q=is%3Aissue+${encodeURIComponent(message)}
-
- or open a new one:
- https://github.com/sindresorhus/refined-github/issues/new?labels=bug&template=bug_report.md&title=${encodeURIComponent(`\`${featureName}\`: ${message}`)}
- `));
+ console.error(
+ `❌ Refined GitHub → ${featureName} →`,
+ 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}`)}
+ `)
+ );
}
export const getUsername = onetime(() => select('meta[name="user-login"]')!.getAttribute('content')!);
@@ -156,17 +158,6 @@ export async function poll<T>(callback: () => T, frequency: number): Promise<T>
});
}
-// TODO: Merge this with `logError`
-export function reportBug(featureName: string, bugName: string): void {
- alert(`Refined GitHub: ${bugName}. Can you report this issue? You’ll find more information in the console.`);
- const issuesUrl = new URL('https://github.com/sindresorhus/refined-github/issues');
- const newIssueUrl = new URL('https://github.com/sindresorhus/refined-github/new?labels=bug&template=bug_report.md');
- issuesUrl.searchParams.set('q', `is:issue ${featureName}`);
- newIssueUrl.searchParams.set('title', `\`${featureName}\` ${bugName}`);
- console.log('Find existing issues:\n' + String(issuesUrl));
- console.log('Open new issue:\n' + String(newIssueUrl));
-}
-
/**
* Prepend `:scope >` to a single or group of css selectors.
* @param {string} selector A css selector.