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

fix-docs
Nolan Lawson 2020-05-30 11:05:13 -07:00 zatwierdzone przez GitHub
rodzic 3476b9dc7e
commit ec8e872f8d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 9 dodań i 5 usunięć

Wyświetl plik

@ -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,

Wyświetl plik

@ -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}