fix: better error message for invalid instances (#1793)
This commit is contained in:
parent
3476b9dc7e
commit
ec8e872f8d
|
@ -8,6 +8,13 @@ import { updateCustomEmojiForInstance } from './emoji'
|
||||||
import { database } from '../_database/database'
|
import { database } from '../_database/database'
|
||||||
import { DOMAIN_BLOCKS } from '../_static/blocks'
|
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) {
|
function createKnownError (message) {
|
||||||
const err = new Error(message)
|
const err = new Error(message)
|
||||||
err.knownError = true
|
err.knownError = true
|
||||||
|
@ -59,10 +66,7 @@ export async function logInToInstance () {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
const error = `${err.message || err.name}. ` +
|
const error = `${err.message || err.name}. ` +
|
||||||
(err.knownError ? '' : (navigator.onLine
|
(err.knownError ? '' : (navigator.onLine ? GENERIC_ERROR : 'Are you offline?'))
|
||||||
? `Is this a valid Mastodon instance? Is a browser extension
|
|
||||||
blocking the request? Are you in private browsing mode?`
|
|
||||||
: 'Are you offline?'))
|
|
||||||
const { instanceNameInSearch } = store.get()
|
const { instanceNameInSearch } = store.get()
|
||||||
store.set({
|
store.set({
|
||||||
logInToInstanceError: error,
|
logInToInstanceError: error,
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
{#if $logInToInstanceError && $logInToInstanceErrorForText === $instanceNameInSearch}
|
{#if $logInToInstanceError && $logInToInstanceErrorForText === $instanceNameInSearch}
|
||||||
<div class="form-error form-error-user-error" role="alert">
|
<div class="form-error form-error-user-error" role="alert">
|
||||||
Error: {$logInToInstanceError}
|
Error: {@html $logInToInstanceError}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue