fix: better error message for invalid instances (#1793)

This commit is contained in:
Nolan Lawson 2020-05-30 11:05:13 -07:00 committed by GitHub
parent 3476b9dc7e
commit ec8e872f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -8,6 +8,13 @@ import { updateCustomEmojiForInstance } from './emoji'
import { database } from '../_database/database'
import { DOMAIN_BLOCKS } from '../_static/blocks'
const GENERIC_ERROR = `
Is this a valid Mastodon instance? Is a browser extension
blocking the request? Are you in private browsing mode?
If you believe this is a problem with your instance, please send
<a href="https://github.com/nolanlawson/pinafore/blob/master/docs/Admin-Guide.md"
target="_blank" rel="noopener">this link</a> to the administrator of your instance.`
function createKnownError (message) {
const err = new Error(message)
err.knownError = true
@ -59,10 +66,7 @@ export async function logInToInstance () {
} catch (err) {
console.error(err)
const error = `${err.message || err.name}. ` +
(err.knownError ? '' : (navigator.onLine
? `Is this a valid Mastodon instance? Is a browser extension
blocking the request? Are you in private browsing mode?`
: 'Are you offline?'))
(err.knownError ? '' : (navigator.onLine ? GENERIC_ERROR : 'Are you offline?'))
const { instanceNameInSearch } = store.get()
store.set({
logInToInstanceError: error,

View File

@ -14,7 +14,7 @@
{#if $logInToInstanceError && $logInToInstanceErrorForText === $instanceNameInSearch}
<div class="form-error form-error-user-error" role="alert">
Error: {$logInToInstanceError}
Error: {@html $logInToInstanceError}
</div>
{/if}